protected static void IgnoreTestIfHiveIsReadOnly(IHive <T> hive) { if (hive.IsReadOnly) { Assert.Ignore("Not applicable to read-only collections."); } }
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); }
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)); }
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); }
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)); }
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)); }
public void RemoveRange(IHive <T> itemsToRemove) { RemoveRange(itemsToRemove.GetEnumerator()); }
public HiveController(AppDBContent context, IHive iHive) { _hive = iHive; db = context; }
protected internal override void AddRange <TInputSize, TInput>(IHive <T, TInputSize, TInput> itemsToAdd) { InsertRange(Count, itemsToAdd); }
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;