示例#1
0
        public void Insert(int index, T item)
        {
            if (index < 0 || index > Count)
            {
                throw new ArgumentException();
            }
            LazinatorLinkedListNode <T> node = new LazinatorLinkedListNode <T>(item);

            if (index == 0)
            {
                node.NextNode = FirstNode;
                FirstNode     = node;
            }
            else
            {
                var previous         = GetNodeAt(index - 1);
                var currentlyAtIndex = previous.NextNode;
                previous.NextNode = node;
                node.NextNode     = currentlyAtIndex;
            }
            Count++;
            _lastAccessedNode  = node;
            _lastAccessedIndex = index;
            ConsiderMultilevelReport(index);
        }
示例#2
0
 public bool MoveNext()
 {
     if (CurrentNode == null)
     {
         CurrentNode = List.FirstNode;
     }
     else
     {
         CurrentNode = CurrentNode.NextNode;
     }
     return(CurrentNode != null);
 }
示例#3
0
 private void LazinateFirstNode()
 {
     if (LazinatorMemoryStorage.Length == 0)
     {
         _FirstNode = null;
     }
     else
     {
         LazinatorMemory childData = GetChildSlice(LazinatorMemoryStorage, _FirstNode_ByteIndex, _FirstNode_ByteLength, null);
         _FirstNode = DeserializationFactory.Instance.CreateBaseOrDerivedType(224, (c, p) => new LazinatorLinkedListNode <T>(c, p), childData, this);
     }
     _FirstNode_Accessed = true;
 }
示例#4
0
 public T this[int index]
 {
     get
     {
         LazinatorLinkedListNode <T> current = GetNodeAt(index);
         return(current.Value);
     }
     set
     {
         LazinatorLinkedListNode <T> current = GetNodeAt(index);
         current.Value = value;
         ConsiderMultilevelReport(index);
     }
 }
示例#5
0
 private LazinatorLinkedListNode <T> GetNodeAt(int index)
 {
     if (index < 0 || index >= Count)
     {
         throw new ArgumentException();
     }
     if (_lastAccessedNode == null || _lastAccessedIndex > index)
     {
         _lastAccessedNode  = FirstNode;
         _lastAccessedIndex = 0;
     }
     for (int i = (int)_lastAccessedIndex; i < index; i++)
     {
         _lastAccessedNode = _lastAccessedNode.NextNode;
         _lastAccessedIndex++;
     }
     return(_lastAccessedNode);
 }
示例#6
0
 public void RemoveAt(int index)
 {
     if (index < 0 || index > Count - 1)
     {
         throw new ArgumentException();
     }
     if (index == 0)
     {
         FirstNode          = FirstNode.NextNode;
         _lastAccessedIndex = null;
         _lastAccessedNode  = null;
     }
     else
     {
         var previous = GetNodeAt(index - 1);
         previous.NextNode  = previous.NextNode?.NextNode;
         _lastAccessedIndex = index - 1;
         _lastAccessedNode  = previous;
     }
     Count--;
     ConsiderMultilevelReport(index);
 }