/// <summary> /// Do not ask any questions, because it really very fast and redundant is also to the point /// Please do learn java performance /// </summary> /// <param name="it">it only iterator from start</param> protected void FindLess(StartIterator it) { int zero = 0; int minLength = 2; List<string> accord = it.Current(); int length = accord.Count; int position = it.Position(); // for less one if (position == zero) { // first less one minusOneEntry.Add(accord.GetRange(0, length - 1), position, 0); minusOneEntry.Add(accord.GetRange(1, length - 1), position, 0); } else { // common less one minusOneEntry.Add(accord.GetRange(1, length - 1), position, 0); } // for less two if (length == minLength) { // do not handle words of length 2 return; } if (position == zero) { // first less two minusTwoEntry.Add(accord.GetRange(1, length - 2), position, 0); return; } int param = it.MaxShifts == it.Shifts ? 0 : 1; minusTwoEntry.Add(accord.GetRange(param, length - 2), position, 0); }
/// <summary> /// The add. /// </summary> /// <param name="iterator"> /// The iterator. /// </param> /// <param name="step"> /// The step. /// </param> public void Add(StartIterator iterator, int step) { List<string> str = iterator.Current(); int position = iterator.Position(); Add(str, position, step); }
public void MoveTest() { int length = 2; int step = 1; int position = 3; var iterator = new StartIterator(chain, length, step); iterator.Move(position); Assert.True(iterator.CursorPosition == position); position = 100; iterator.Move(position); Assert.True(iterator.CursorPosition != position); position = chain.GetLength() / 2; iterator.Move(position); Assert.True(iterator.CursorPosition == position); position = -1; iterator.Move(position); Assert.True(iterator.CursorPosition != position); length = 3; step = 2; position = 3; string triple = "GTG"; iterator = new StartIterator(chain, length, step); iterator.Move(position); iterator.Next(); Assert.AreEqual(triple, Helper.ToString(iterator.Current())); }