static void RandomTreeInsert(IIntervalTree <int, string> tree, int limit) { var a = random.Next(limit); var b = random.Next(limit); tree.Add(Math.Min(a, b), Math.Max(a, b), "value"); }
private IIntervalTree <Position, ILocalizableSymbol> ApplyLookupTreeChange( IIntervalTree <Position, ILocalizableSymbol> previousLookupTree, Range changeRange, Position afterChangeEndOffset ) { var migratedLookupTree = new IntervalTree <Position, ILocalizableSymbol>(); foreach (var entry in previousLookupTree) { cancellationToken.ThrowIfCancellationRequested(); if (IsPositionBeforeChange(changeRange, entry.To)) { migratedLookupTree.Add(entry.From, entry.To, entry.Value); } if (IsPositionAfterChange(changeRange, entry.From)) { var beforeChangeEndOffset = changeRange.End; var from = GetPositionWithOffset(entry.From, beforeChangeEndOffset, afterChangeEndOffset); var to = GetPositionWithOffset(entry.To, beforeChangeEndOffset, afterChangeEndOffset); migratedLookupTree.Add(from, to, entry.Value); } } return(migratedLookupTree); }
public void Add(TKey @from, TKey to, TValue value) { if (values == null) { values = new IntervalTree <TKey, TValue>(); values.Add(this.value.start, this.value.end, this.value.value); } values.Add(@from, to, value); }
public SymbolTable( CompilationUnit compilationUnit, IDictionary <AstElement, ILocalizableSymbol> declarations, IDictionary <ISymbol, SymbolLocation> locations, IIntervalTree <Position, ILocalizableSymbol> lookupTree, bool symbolsResolved ) { CompilationUnit = compilationUnit; Declarations = declarations; Locations = locations; LookupTree = lookupTree; Resolved = symbolsResolved; typeResolver = new DafnyLangTypeResolver(declarations); // TODO IntervalTree goes out of sync after any change and "fixes" its state upon the first query. Replace it with another implementation that can be queried without potential side-effects. LookupTree.Query(new Position(0, 0)); }