public bool MoveNext() { if (_row < Constants.NumberOfSegmentsByType) { _index = _row++; _type = IteratorType.Row; return(true); } if (_col < Constants.NumberOfSegmentsByType) { _index = _col++; _type = IteratorType.Column; return(true); } if (_subGrid < Constants.NumberOfSegmentsByType) { _index = _subGrid++; _type = IteratorType.SubGrid; return(true); } return(false); }
public CommandIterator(IteratorType type, string selectionString, StyleType style, string filter) : this() { this.Type = type; this.SelectionString = selectionString; this.Style = style; this.Filter = filter; this.Selection = ParseSelectionType(selectionString); }
// Iterator: Returns an iterator depending on the input. // IteratorType: The type of itterator that should be returned. // - SortedByAge: Will sort the dataset by age. // - SortedByName: Will sort the dataset by name. // - NotSorted: Will leave the dataset as is. // // Calls the declared CreateIterator method. public override Iterator CreateIterator(IteratorType iteratorType) { switch (iteratorType) { case IteratorType.SortedByAge: return(SortedByAge()); case IteratorType.SortedByName: return(SortedByName()); default: return(new ConcreteIterator(this)); } }
void CollectionName_KeyDown(Block block, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == System.Windows.Forms.Keys.Tab) { IteratorType.SetFocus(); e.Handled = true; } if (e.KeyCode == System.Windows.Forms.Keys.Back) { IteratorName.SetCursorToTheEnd(); e.Handled = true; } }
protected CommonIterator( IHandler handler, string channelId, string txId, QueryResponse response, IteratorType type ) { _handler = handler; _channelId = channelId; _txId = txId; _response = response; _type = type; }
public ISegmentIterator GetIterator(IteratorType type, Puzzle puzzle, int index) { switch (type) { case IteratorType.Row: return(new RowIterator(puzzle, index)); case IteratorType.Column: return(new ColumnIterator(puzzle, index)); case IteratorType.SubGrid: return(new SubGridIterator(puzzle, index)); default: throw new ArgumentException("Invalid Iterator Type."); } }
public override Iterator CreateIterator(IteratorType it) { Iterator retVal; switch (it) { case IteratorType.TotalIterator: retVal = CreateTotalIterator(this); break; case IteratorType.LetterIterator: retVal = CreateLetterIterator(this); break; default: retVal = CreateTotalIterator(this); break; } return(retVal); }
public override IIterator CreateIterator(IteratorType iteratorType) { switch (iteratorType) { case IteratorType.Sequential: return(new SequentialIterator(this)); case IteratorType.AscendingValue: return(new AscendingIdentifierIterator(this)); case IteratorType.DescendingValue: return(new DescendingIdentifierIterator(this)); case IteratorType.Random: return(new RandomIterator(this)); default: return(new SequentialIterator(this)); } }
public NDIterator(IMemoryBlock block, Shape shape, Shape?broadcastedShape, bool autoReset = false) { if (shape.IsEmpty || shape.size == 0) { throw new InvalidOperationException("Can't construct NDIterator with an empty shape."); } Block = block ?? throw new ArgumentNullException(nameof(block)); Shape = shape; BroadcastedShape = broadcastedShape; if (broadcastedShape.HasValue && shape.size != broadcastedShape.Value.size) { AutoReset = true; } else { AutoReset = autoReset; } // ReSharper disable once MergeConditionalExpression size = broadcastedShape.HasValue ? broadcastedShape.Value.size : shape.size; if (shape.IsScalar) { Type = IteratorType.Scalar; } else if (shape.NDim == 1) { Type = IteratorType.Vector; } else if (shape.NDim == 2) { Type = IteratorType.Matrix; } else { Type = IteratorType.Tensor; } SetDefaults(); }
public Iterator CreateIterator(IteratorType iter) { //return new CompleteIterator(this); switch (iter) { case IteratorType.completeIterator: return(new CompleteIterator(this)); case IteratorType.aIterator: return(new AIterator(this)); case IteratorType.bIterator: return(new BIterator(this)); case IteratorType.cIterator: return(new CIterator(this)); default: return(new CompleteIterator(this)); } }
public Iterator CreateIterator(IteratorType amount) { Iterator returnVal = null; switch (amount) { case IteratorType.Verizon: returnVal = CreateVerizonIterator(this); break; case IteratorType.ATNT: returnVal = CreateATNTIterator(this); break; case IteratorType.Sprint: returnVal = CreateSprintIterator(this); break; case IteratorType.TMobile: returnVal = CreateTMobileIterator(this); break; } return(returnVal); }
public Iterator CreateIterator(IteratorType it) { Iterator retVal; switch (it) { case IteratorType.TotalIterator: retVal = CreateTotalIterator(this); break; case IteratorType.SquaresIterator: retVal = CreateEvenIterator(this); break; case IteratorType.PrimeIterator: retVal = CreateOddIterator(this); break; default: retVal = CreateTotalIterator(this); break; } return(retVal); }
public abstract Iterator CreateIterator(IteratorType iteratorType);
internal static bool IsAsync(IteratorType iterType) => iterType == IteratorType.AsyncByteVector || iterType == IteratorType.AsyncMemoryOwner;
private IteratorPosition(IteratorType origin, string offset = null) { Origin = origin; Offset = offset; }
public static T Map <T>(IteratorType iteratorType) { return((T)Enum.Parse(typeof(T), iteratorType.ToString())); }
public async ValueTask FlakyLogTestTolerateFailure([Values] IteratorType iteratorType) { var errorOptions = new ErrorSimulationOptions { readTransientErrorRate = 0, readPermanentErrorRate = 0, writeTransientErrorRate = 0, writePermanentErrorRate = 0.1, }; device = new SimulatedFlakyDevice(Devices.CreateLogDevice(path + "fasterlog.log", deleteOnClose: true), errorOptions); var logSettings = new FasterLogSettings { LogDevice = device, LogChecksum = LogChecksumType.PerEntry, LogCommitManager = manager, TolerateDeviceFailure = true }; log = new FasterLog(logSettings); byte[] entry = new byte[entryLength]; for (int i = 0; i < entryLength; i++) { entry[i] = (byte)i; } // Ensure we write enough to trigger errors for (int i = 0; i < 1000; i++) { log.Enqueue(entry); try { if (IsAsync(iteratorType)) { await log.CommitAsync(); } else { log.Commit(); } } catch (CommitFailureException) { // Ignore failure } } // For surviving entries, scan should still work best-effort // If endAddress > log.TailAddress then GetAsyncEnumerable() will wait until more entries are added. var endAddress = IsAsync(iteratorType) ? log.CommittedUntilAddress : long.MaxValue; var recoveredLog = new FasterLog(logSettings); using var iter = recoveredLog.Scan(0, endAddress); switch (iteratorType) { case IteratorType.AsyncByteVector: await foreach ((byte[] result, int _, long _, long nextAddress) in iter.GetAsyncEnumerable()) { Assert.IsTrue(result.SequenceEqual(entry)); } break; case IteratorType.AsyncMemoryOwner: await foreach ((IMemoryOwner <byte> result, int _, long _, long nextAddress) in iter.GetAsyncEnumerable(MemoryPool <byte> .Shared)) { Assert.IsTrue(result.Memory.Span.ToArray().Take(entry.Length).SequenceEqual(entry)); result.Dispose(); } break; case IteratorType.Sync: while (iter.GetNext(out byte[] result, out _, out _)) { Assert.IsTrue(result.SequenceEqual(entry)); } break; default: Assert.Fail("Unknown IteratorType"); break; } recoveredLog.Dispose(); }