correct Delete operation behavior

This commit is contained in:
2021-07-27 17:17:34 +08:00
parent e4c6da9990
commit 250dff7107
3 changed files with 38 additions and 18 deletions

View File

@ -33,21 +33,27 @@ namespace BallanceTASEditor.Core {
// for (int i = 0; i < count; i++) list.RemoveAt(index);
//}
// remove safety. because it store the next node.
public static IEnumerable<LinkedListNode<FrameData>> IterateFullReversed(this LinkedList<FrameData> ls) {
var pos = ls.Last;
LinkedListNode<FrameData> cacheNextNode;
while (pos != null) {
cacheNextNode = pos.Previous;
yield return pos;
pos = pos.Previous;
pos = cacheNextNode;
}
}
// remove safety. because it store the next node.
public static IEnumerable<LinkedListNode<FrameData>> IterateFull(this LinkedList<FrameData> ls) {
var pos = ls.First;
LinkedListNode<FrameData> cacheNextNode;
while(pos != null) {
cacheNextNode = pos.Next;
yield return pos;
pos = pos.Next;
pos = cacheNextNode;
}
}