예제 #1
0
        /// <summary>
        /// Remove obsolete versions.
        /// </summary>
        public Siblings Discard(Siblings s, VersionVector context)
        {
            Ensure.That(s, "s").IsNotNull();
            Ensure.That(context, "context").IsNotNull();

            // discard all siblings that are obsolete because they are included
            // in the context.
            IEnumerable <VersionedObject> concurrent = s.Where(sibling => !sibling.Clock.HappensBefore(context));

            return(new Siblings(concurrent));
        }
예제 #2
0
        public Siblings Sync(Siblings s1, Siblings s2)
        {
            Ensure.That(s1, "s1").IsNotNull();
            Ensure.That(s2, "s2").IsNotNull();

            IEnumerable <VersionedObject> r1 = s1.Where(sibling1 => !s2.Any(sibling1.HappensBefore));
            IEnumerable <VersionedObject> r2 = s2.Where(sibling2 => !s1.Any(sibling2.HappensBefore));

            IEnumerable <VersionedObject> union = r1.Union(r2).ToList();

            return(new Siblings(union));
        }