Exemplo n.º 1
0
 public EnumerableSurrogate(ReferenceMultiRankMap <KeyType, ValueType> map, bool forward, bool robust, bool startKeyed, KeyType startKey)
 {
     this.map        = map;
     this.forward    = forward;
     this.robust     = robust;
     this.startKeyed = startKeyed;
     this.startKey   = startKey;
 }
Exemplo n.º 2
0
        public void ConditionalSetOrRemove(KeyType key, UpdatePredicate <KeyType, ValueType> predicate)
        {
            if (predicate == null)
            {
                throw new ArgumentNullException();
            }

            ValueType value;
            bool      resident = TryGetValue(key, out value);

            uint version = inner.version;
            ReferenceMultiRankMap <KeyType, ValueType> savedInner = inner;

            inner         = new ReferenceMultiRankMap <KeyType, ValueType>();
            inner.version = savedInner.version;

            bool remove = predicate(key, ref value, resident);

            savedInner.version = inner.version;
            inner = savedInner;
            if (version != inner.version)
            {
                throw new InvalidOperationException();
            }

            if (resident)
            {
                if (remove)
                {
                    bool f = TryRemove(key);
                    Debug.Assert(f);
                }
                else
                {
                    bool f = TrySetValue(key, value);
                    Debug.Assert(f);
                }
            }
        }
Exemplo n.º 3
0
 public ReferenceMultiRankMap(ReferenceMultiRankMap <KeyType, ValueType> original)
 {
     items.AddRange(original.items);
 }
Exemplo n.º 4
0
 public ReferenceRankMap(ReferenceRankMap <KeyType, ValueType> original)
 {
     inner = new ReferenceMultiRankMap <KeyType, ValueType>(original.inner);
 }