예제 #1
0
파일: ISparseList.cs 프로젝트: bel-uwa/Loyc
        /// <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));
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
 /// <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);
 }
예제 #4
0
 public SparseAList(ISparseListSource <T> items)
 {
     InsertRange(0, items);
 }
예제 #5
0
 void ISparseListEx <T> .InsertRange(int index, ISparseListSource <T> list)
 {
     InsertRange(index, list);
 }
예제 #6
0
파일: ISparseList.cs 프로젝트: bel-uwa/Loyc
 /// <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);
 }