public P_Set <T> Remove(T value)
        {
            if (Adds.Any(e => e.Id == value.Id))
            {
                return(new(Adds, Removes.Add(value)));
            }

            return(this);
        }
Example #2
0
        public bool Lookup(T value)
        {
            if (Removes.Any(r => Equals(r, value)))
            {
                return(false);
            }

            return(Adds.Any(r => Equals(r, value)));
        }
Example #3
0
        public LWW_SetWithVC <T> Remove(T value, VectorClock vectorClock)
        {
            if (Adds.Any(a => Equals(a.Value, value) && a.VectorClock < vectorClock))
            {
                var element = Removes.FirstOrDefault(r => r.Value.Id == value.Id);

                ImmutableHashSet <LWW_SetWithVCElement <T> > elements = Removes;

                if (element is not null)
                {
                    elements = Removes.Remove(element);
                }

                return(new(Adds, elements.Add(new LWW_SetWithVCElement <T>(value, vectorClock))));
            }

            return(this);
        }
Example #4
0
        public LWW_Set <T> Remove(T value, long timestamp)
        {
            if (Adds.Any(a => Equals(a.Value, value) && a.Timestamp < timestamp))
            {
                var element = Removes.FirstOrDefault(r => r.Value.Id == value.Id);

                ImmutableHashSet <LWW_SetElement <T> > elements = Removes;

                if (element is not null)
                {
                    elements = Removes.Remove(element);
                }

                return(new(Adds, elements.Add(new LWW_SetElement <T>(value, timestamp))));
            }

            return(this);
        }