Ejemplo n.º 1
0
            public override bool Equals(object obj)
            {
                Pair rhs = obj as Pair;

                return(rhs == null ? false : Key.Equals(rhs.Key) && Value.Equals(rhs.Value));
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Move all current branches to the next search node that corresponds to the specified key.
            /// Returns if there is at least one value on the current branches.
            /// </summary>
            public bool Next(TKey key)
            {
                // skip if no branches
                if (!_root.LeavesSet)
                {
                    return(false);
                }

                // reset the current values
                Values.Reset();

                // get the branches to iterate
                int count = _branches.Count;

                // always check the root branch
                foreach (Branch leaf in _root.Leaves)
                {
                    bool match = false;

                    // iterate the keys
                    foreach (TKey k in leaf.Keys)
                    {
                        // does the key match?
                        if (key.Equals(k))
                        {
                            // no, flip the match flag
                            match = true;
                            break;
                        }
                    }

                    // does the match state equal the leaf exclusivity?
                    if (match != leaf.Not)
                    {
                        // yes, add next branch
                        _branches.Enqueue(leaf);
                        // if value - add it
                        if (leaf.ValueSet)
                        {
                            Values.Add(leaf.Value);
                        }
                    }
                }

                // get the number of branches to process
                if (count > 0)
                {
                    // iterate branches to search
                    do
                    {
                        _branches.Dequeue();
                        if (_branches.Current.LeavesSet)
                        {
                            // iterate leaves of current branches
                            foreach (Branch leaf in _branches.Current.Leaves)
                            {
                                bool match = false;

                                // iterate the keys and check for matches
                                foreach (TKey k in leaf.Keys)
                                {
                                    // does the key match?
                                    if (key.Equals(k))
                                    {
                                        // no, flip the match flag
                                        match = true;
                                        break;
                                    }
                                }

                                // does the match state equal the leaf exclusivity?
                                if (match != leaf.Not)
                                {
                                    // yes, add next branch
                                    _branches.Enqueue(leaf);
                                    // if value - add it
                                    if (leaf.ValueSet)
                                    {
                                        Values.Add(leaf.Value);
                                    }
                                }
                            }
                        }
                    } while(--count != 0);
                }

                return(Values.Count != 0);
            }
Ejemplo n.º 3
0
 public bool Equals(ChangeWithGroup other)
 {
     return(_key.Equals(other._key));
 }