Beispiel #1
0
        public BinaryTrieNode FindExactMatch(Int32 key)
        {
            if ((key ^ _key) == 0)
            {
                return(this);
            }

            // Pick the child to investigate.
            if ((key & _bit[_keyLength + 1]) == 0)
            {
                // If the key matches the child's key, pass on the request.
                if (null != _zero)
                {
                    if ((key ^ _zero._key) < _bit[_zero._keyLength])
                    {
                        return(_zero.FindExactMatch(key));
                    }
                }
            }
            else
            {
                // If the key matches the child's key, pass on the request.
                if (null != _one)
                {
                    if ((key ^ _one._key) < _bit[_one._keyLength])
                    {
                        return(_one.FindExactMatch(key));
                    }
                }
            }
            // If we got here, neither child was a match, so the current
            // node is the best match.
            return(null);
        }
Beispiel #2
0
        protected Object FindExactMatchInternal(Int32 index, Int32 key)
        {
            BinaryTrieNode root = _roots[index];

            if (null == root)
            {
                return(null);
            }
            return(root.FindExactMatch(key).UserData);
        }