public void RemoveAtIndex(int index) { if (index > Length - 1) { throw new IndexOutOfRangeException(); } else if (index == Length - 1) { Pop(); } else if (index == 0) { RemoveFirst(); } else { LinkedListIterator <T> iter = this.Iterator(); while (iter.CurrentIndex < index) { iter.Next(); } iter.Remove(); Length--; } }
public void Remove(T item) { LinkedListIterator <T> iter = this.Iterator(); while (iter.HasNext()) { if (iter.Next().Equals(item)) { iter.Remove(); Length--; } } }
private Event PeekEvent() { return(locker.Synchronized(() => { LinkedListIterator <Event> i = iterator++; Event message = i.Value; LinkedListNode <Event> node = i.Node; if (node != null) { events.Remove(node); iterator.Remove(node); } return message; })); }
internal bool Stop(Timer timer) { lock (this) { if (_disposed) { return(false); } if (timer == null) { return(false); } LinkedListNode <Timer> n; if (!_m.TryGetValue(timer, out n)) { return(false); } _s.Remove(n); _m.Remove(timer); _i.Remove(n); return(true); } }
private void handleFileSwap(LinkedListIterator<FileSystemEventArgs> renameIterator, LinkedListIterator<FileSystemEventArgs> deleteIterator) { FileSystemEventArgs delete = deleteIterator.Current; Utils.LinkedListIterator<FileSystemEventArgs> innerIterator = renameIterator.Clone(); while (innerIterator.hasNext()) { FileSystemEventArgs nextChange = innerIterator.Next(); if(nextChange == delete) { return; } RenamedEventArgs erlierRename = renameIterator.Current as RenamedEventArgs; RenamedEventArgs rename = nextChange as RenamedEventArgs; if (rename != null && Object.Equals(erlierRename.OldFullPath, rename.FullPath)) { //this is a file swap! renameIterator.Remove(); innerIterator.Remove(); deleteIterator.Current = new FileSystemEventArgs( WatcherChangeTypes.Changed, Path.GetDirectoryName(erlierRename.OldFullPath), Path.GetFileName(erlierRename.OldFullPath)); //remove any events related to temporary swap file (rename.OldFullPath) string tmpFileFullPath = rename.OldFullPath; Utils.LinkedListIterator<FileSystemEventArgs> tmpIterator = renameIterator.Clone(); while (tmpIterator.HasPrevious()) { FileSystemEventArgs e = tmpIterator.Previous(); if(Object.Equals(e.FullPath, tmpFileFullPath)) { if(e.ChangeType == WatcherChangeTypes.Renamed){ handleRenamed(tmpIterator); if (tmpIterator.Current != null && tmpIterator.Current.ChangeType == WatcherChangeTypes.Renamed) { tmpFileFullPath = ((RenamedEventArgs)tmpIterator.Current).OldFullPath; } } if (tmpIterator.Current != null) { tmpIterator.Remove(); } } } } } }