Beispiel #1
0
 public bool Equals(ZipResult other)
 {
     return
         (this.m_CommonHead == other.m_CommonHead &&
          this.m_OtherRest == other.m_OtherRest &&
          this.m_ThisRest == other.m_ThisRest);
 }
 public bool Equals(ZipResult other)
 {
     return
         this.m_CommonHead == other.m_CommonHead &&
         this.m_OtherRest == other.m_OtherRest &&
         this.m_ThisRest == other.m_ThisRest;
 }
Beispiel #3
0
        private void SplitOne(ZipResult zipResult, TValue value)
        {
            var leftChild = new PatriciaTrieNode <TValue>(zipResult.ThisRest, this.m_Values, this.m_Children);

            this.m_Children = new Dictionary <char, PatriciaTrieNode <TValue> >();
            this.m_Values   = new Queue <TValue>();
            this.AddValue(value);
            this.m_Key = zipResult.CommonHead;

            this.m_Children.Add(zipResult.ThisRest[0], leftChild);
        }
Beispiel #4
0
        private void SplitTwo(ZipResult zipResult, TValue value)
        {
            var leftChild  = new PatriciaTrieNode <TValue>(zipResult.ThisRest, this.m_Values, this.m_Children);
            var rightChild = new PatriciaTrieNode <TValue>(zipResult.OtherRest, value);

            this.m_Children = new Dictionary <char, PatriciaTrieNode <TValue> >();
            this.m_Values   = new Queue <TValue>();
            this.m_Key      = zipResult.CommonHead;

            char leftKey = zipResult.ThisRest[0];

            this.m_Children.Add(leftKey, leftChild);
            char rightKey = zipResult.OtherRest[0];

            this.m_Children.Add(rightKey, rightChild);
        }
Beispiel #5
0
        internal virtual void Add(StringPartition keyRest, TValue value)
        {
            ZipResult zipResult = this.m_Key.ZipWith(keyRest);

            switch (zipResult.MatchKind)
            {
            case MatchKind.ExactMatch:
                this.AddValue(value);
                break;

            case MatchKind.IsContained:
                this.GetOrCreateChild(zipResult.OtherRest, value);
                break;

            case MatchKind.Contains:
                this.SplitOne(zipResult, value);
                break;

            case MatchKind.Partial:
                this.SplitTwo(zipResult, value);
                break;
            }
        }