internal int DecrementCount(TokenPredictorInfo child, int increment) { Debug.Assert(ReferenceEquals(child, _database[child.Token])); var value = child.DecrementCount(increment); _isSortedDatabaseValid = false; return(value); }
private int SortedDictionaryComparison(TokenPredictorInfo x, TokenPredictorInfo y) { var value = y.Count.CompareTo(x.Count); if (value == 0) { value = y.Token.CompareTo(x.Token); } return(value); }
internal TokenPredictorInfo GetValue(int token) { if (!_database.TryGetValue(token, out var info)) { info = new TokenPredictorInfo(token); _database.Add(token, info); if (_sortedDatabase != null) { _sortedDatabase.Add(info); _isSortedDatabaseValid = false; } Debug.Assert(!_isSortedDatabaseValid); } return(info); }
internal bool TryGetValue(int token, out TokenPredictorInfo info) { var value = _database.TryGetValue(token, out info); return(value); }
internal void IncrementCount(TokenPredictorInfo child, int increment) { Debug.Assert(ReferenceEquals(child, _database[child.Token])); child.IncrementCount(increment); _isSortedDatabaseValid = false; }
private static IDictionary <string, object> ToJsonDictionary(StringTokens tokens, TokenPredictorInfo info) { var saved = new SortedDictionary <string, object> { { "#", info.Count } }; var children = info.TryGetChildren(); if (children != null) { var value = ToJsonDictionary(tokens, children); saved.Add("~", value); } return(saved); }