Exemplo n.º 1
0
        private WordMetadata GetWordMetadata(string word)
        {
            WordMetadata newMetadata =
                _wordsMetadata.GetOrAdd(word, (key) => new WordMetadata
            {
                Index      = Interlocked.Increment(ref lastWordIndex),
                Occurances = 0
            });


            return(newMetadata);
        }
Exemplo n.º 2
0
        public int GetWordIndex2(string word)
        {
            //int index;
            //index = _words.GetOrAdd(word, Interlocked.Increment(ref lastWordIndex));
            WordMetadata newMetadata =
                _wordsMetadata.GetOrAdd(word, (key) => new WordMetadata
            {
                Index      = Interlocked.Increment(ref lastWordIndex),
                Occurances = 0
            });


            return(newMetadata.Index);
        }
Exemplo n.º 3
0
 private bool TryGetExistingWordMetadata(string word, out WordMetadata result)
 {
     return(_wordsMetadata.TryGetValue(word, out result));
 }