Esempio n. 1
0
        internal void AddElement(IRingIdentifier <T> element)
        {
            lock (lockable)
            {
                if (sortedRingList.Contains(element))
                {
                    // we already have this element
                    return;
                }

                uint hash = element.GetUniformHashCode();

                // insert new element in the sorted order
                // Find the last element with hash smaller than the new element, and insert the latter after (this is why we have +1 here) the former.
                // Notice that FindLastIndex might return -1 if this should be the first element in the list, but then
                // 'index' will get 0, as needed.
                int index = sortedRingList.FindLastIndex(elem => elem.GetUniformHashCode() < hash) + 1;

                sortedRingList.Insert(index, element);
            }
        }
Esempio n. 2
0
 public T CalculateResponsible <R>(IRingIdentifier <R> element)
 {
     return(CalculateResponsible(element.GetUniformHashCode()));
 }
Esempio n. 3
0
 internal void RemoveElement(IRingIdentifier <T> element)
 {
     throw new NotImplementedException();
 }