Exemplo n.º 1
0
 protected static void IgnoreTestIfHiveIsReadOnly(IHive <T> hive)
 {
     if (hive.IsReadOnly)
     {
         Assert.Ignore("Not applicable to read-only collections.");
     }
 }
Exemplo n.º 2
0
        internal static bool TryCount <T, TSize>(IEnumerable <T> items, out TSize count)
            where TSize : struct, IConvertible
        {
            IHive <T, TSize> hive = items as IHive <T, TSize>;

            if (hive != null)
            {
                return(hive.TryGetCount(out count));
            }

            ICollection <T> collection = items as ICollection <T>;
            int             itemCount  = collection != null
                ? collection.Count
                : -1;

            count = SizeOperations <TSize> .Default.From(itemCount);

            return(itemCount >= 0);
        }
Exemplo n.º 3
0
        protected override void OnInsertRange <TInputSize, TInput>
            (Iterator position, IHive <T, TInputSize, TInput> range, out Range <T, TSize, Iterator> insertedRange)
        {
            TSize beginIndex = position.Key;
            TSize endIndex;

            TInputSize itemCount;

            if (range.TryGetCount(out itemCount))
            {
                endIndex = Size.Add(beginIndex, Size.From <TInputSize>(itemCount));
                EnsureSpaceExists(beginIndex, endIndex);

                TSize targetIndex = beginIndex;
                for (TInput i = range.Begin; !i.Equals(range.End); i.Increment())
                {
                    Size.SetValueInArray(_innerArray, i.Read(), targetIndex);
                    Size.Increment(ref targetIndex);
                }
            }
            else
            {
                StreamBuffer <T, TSize, TSizeOperations> snapshot =
                    StreamBuffer <T, TSize, TSizeOperations> .Create(range);

                endIndex = Size.Add(beginIndex, snapshot.Count);

                if (Size.Compare(snapshot.Count, Size.Zero) > 0)
                {
                    EnsureSpaceExists(beginIndex, endIndex);
                    snapshot.CopyTo(_innerArray, beginIndex);
                }
            }

            insertedRange = new Range <T, TSize, Iterator>(position, new Iterator(this, endIndex));
        }
Exemplo n.º 4
0
        protected override void OnInsertRange <TInputSize, TInput>(
            Iterator position, IHive <T, TInputSize, TInput> range, out Range <T, int, Iterator> insertedRange)
        {
            Iterator insertedEnd;

            if (position.IsEnd)
            {
                for (TInput i = range.Begin; !i.Equals(range.End); i.Increment())
                {
                    _innerList.Add(i.Read());
                }
                insertedEnd = End;
            }
            else
            {
                int targetIndex = position.Key;
                for (TInput i = range.Begin; !i.Equals(range.End); i.Increment())
                {
                    _innerList.Insert(targetIndex++, i.Read());
                }
                insertedEnd = new Iterator(this, targetIndex);
            }
            insertedRange = new Range <T, int, Iterator>(position, insertedEnd);
        }
Exemplo n.º 5
0
 protected internal virtual void AddRange <TInputSize, TInput>(IHive <T, TInputSize, TInput> itemsToAdd)
     where TInput : struct, IInputIterator <T, TInputSize, TInput>
     where TInputSize : struct, IConvertible
 {
     AddRange(new HiveEnumerator <T, TInputSize, TInput>(itemsToAdd));
 }
Exemplo n.º 6
0
 protected internal void RemoveRange <TInputSize, TInput>(IHive <T, TInputSize, TInput> itemsToRemove)
     where TInput : struct, IInputIterator <T, TInputSize, TInput>
     where TInputSize : struct, IConvertible
 {
     RemoveRange(new HiveEnumerator <T, TInputSize, TInput>(itemsToRemove));
 }
Exemplo n.º 7
0
 public void RemoveRange(IHive <T> itemsToRemove)
 {
     RemoveRange(itemsToRemove.GetEnumerator());
 }
Exemplo n.º 8
0
 public HiveController(AppDBContent context, IHive iHive)
 {
     _hive = iHive;
     db    = context;
 }
Exemplo n.º 9
0
 protected internal override void AddRange <TInputSize, TInput>(IHive <T, TInputSize, TInput> itemsToAdd)
 {
     InsertRange(Count, itemsToAdd);
 }
Exemplo n.º 10
0
 protected abstract void OnInsertRange <TInputSize, TInput>
     (Iterator insertBegin, IHive <T, TInputSize, TInput> range, out Range <T, TSize, Iterator> insertedRange)
     where TInput : struct, IInputIterator <T, TInputSize, TInput>
     where TInputSize : struct, IConvertible;