/// <summary>Returns the non-cleared items in the sparse list, along with /// their indexes, sorted by index.</summary> /// <remarks> /// The returned sequence should exactly match the set of indexes for which /// <c>list.IsSet(Key)</c> returns true.</remarks> public static IEnumerable <KeyValuePair <int, T> > Items <T>(this ISparseListSource <T> list) { int?i = null; for (;;) { T value = list.NextHigherItem(ref i); if (i == null) { break; } yield return(new KeyValuePair <int, T>(i.Value, value)); } }
public void InsertRange(int index, ISparseListSource <T> list) { AutoThrow(); var count = list.Count; DetectSizeOverflow(count); if (count <= 0) { return; } var op = new AListSparseOperation <T>((uint)index, true, false, count, _observer) { Source = list, SparseSource = list }; DoSparseOperation(ref op); }
/// <summary>Returns <c>list</c> itself. This overload exists to prevent you from /// accidentally wrapping a sparse list in <see cref="ListSourceAsSparse{T}"/>, /// which would block access to knowledge of any empty spaces in the list.</summary> public static ISparseListSource <T> AsSparse <T>(this ISparseListSource <T> list) { return(list); }
public SparseAList(ISparseListSource <T> items) { InsertRange(0, items); }
void ISparseListEx <T> .InsertRange(int index, ISparseListSource <T> list) { InsertRange(index, list); }
/// <summary>Gets the next lower index that is not classified as an /// empty space, or null if there are no non-blank lower indexes.</summary> /// <remarks>This extension method works by calling <c>NextHigherItem()</c>.</remarks> public static int?NextLowerIndex <T>(this ISparseListSource <T> list, int?index) { list.NextLowerItem(ref index); return(index); }