Exemplo n.º 1
0
            public Bucket Except <TValue2>(HashedAvlTree <TKey, TValue2> .Bucket other, Lineage lineage,
                                           ValueSelector <TKey, TValue, TValue2, Optional <TValue> > subtraction = null)
            {
                var newBucket = Empty;

                foreach (var item in Items)
                {
                    var findOther = other.Find(item.Key);
                    if (findOther.IsNone)
                    {
                        newBucket = NewBucket(item.Key, item.Value, newBucket, lineage);
                    }
                    else if (subtraction != null)
                    {
                        var newValue = subtraction(item.Key, item.Value, findOther.Value);
                        if (newValue.IsSome)
                        {
                            newBucket = NewBucket(item.Key, newValue.Value, newBucket, lineage);
                        }
                    }
                }
                return(newBucket);
            }