Exemple #1
0
        public int NextFreeId(LocStringTableIndexRange range)
        {
            Contract.Requires(range != null);

            if (UsedIndices.Length == 0)
            {
                return(range.StartIndex);
            }

            int max_index = UsedIndices.Length - 1;

            if (range.StartIndex > max_index)
            {
                return(range.StartIndex);
            }

            for (int clear_bit_index = range.StartIndex; (clear_bit_index = UsedIndices.NextClearBitIndex(clear_bit_index)) > 0;)
            {
                if (clear_bit_index > range.EndIndex)
                {
                    break;
                }

                return(clear_bit_index);
            }

            if (range.EndIndex > max_index)
            {
                return(max_index + 1);
            }

            return(TypeExtensions.kNone);
        }
Exemple #2
0
        public static LocStringTableIndexRange FindRangeDefinition(int index)
        {
            Contract.Requires(index >= 0);

            LocStringTableIndexRange found_range = null;

            for (var range = IndexRanges; range != null;)
            {
                if (index >= range.StartIndex && index <= range.EndIndex)
                {
                    found_range = range;

                    if (range.SubRanges.IsNotNullOrEmpty())
                    {
                        range = range.SubRanges[0];
                        continue;
                    }

                    break;
                }

                range = range.NextRange;
            }

            return(found_range);
        }
Exemple #3
0
        internal LocStringTableIndexRange MakeNextRange(int count, string reservedFor)
        {
            var next = new LocStringTableIndexRange(this, count, reservedFor);

            this.NextRange = next;

            return(next);
        }
Exemple #4
0
        internal LocStringTableIndexRange StartSubRange(int count, string reservedFor)
        {
            var first_child = new LocStringTableIndexRange(count, reservedFor);

            first_child.Parent     = this;
            first_child.Depth      = this.Depth + 1;
            first_child.StartIndex = this.StartIndex;

            SubRanges = new List <LocStringTableIndexRange>();
            SubRanges.Add(first_child);

            return(first_child);
        }
Exemple #5
0
        public LocStringTableIndexRange(LocStringTableIndexRange prev, int count, string reservedFor)
        {
            if (prev != null)
            {
                PrevRange  = prev;
                Parent     = prev.Parent;
                Depth      = prev.Depth;
                StartIndex = prev.Count;
            }
            else
            {
                StartIndex = 0;
            }

            Count       = count;
            ReservedFor = reservedFor;

            if (Parent != null)
            {
                Parent.SubRanges.Add(this);
            }
        }
Exemple #6
0
        private int CountNumberUsed(LocStringTableIndexRange range)
        {
            Contract.Requires(range != null);

            int used_count = 0;

            if (range.StartIndex >= UsedIndices.Length)
            {
                return(used_count);
            }

            foreach (int bit_index in UsedIndices.SetBitIndicesStartingAt(range.StartIndex))
            {
                if (bit_index > range.EndIndex)
                {
                    break;
                }

                used_count++;
            }

            return(used_count);
        }