コード例 #1
0
        public IBitmappedTrie <A> Suffix(A value)
        {
            if (Count < 16)
            {
                var newArray = array.ToArray();
                newArray[Count] = value;
                return(new BitmappedTrieLeaf <A>(Count + 1, newArray));
            }

            var sibiling = new A[16];

            sibiling[0] = value;
            var parent = new IBitmappedTrie <A> [16];

            parent[0] = this;
            parent[1] = new BitmappedTrieLeaf <A>(1, sibiling);
            return(new BitmappedTrieBranch <A>(Count + 1, 1, parent));
        }
コード例 #2
0
        public IBitmappedTrie <A> Suffix(A value)
        {
            if (Count < (16 << (depth * 4)))
            {
                var offset      = depth * 4;
                var child       = (Count >> offset) & 15;
                var newChildren = array.ToArray();
                newChildren[child] = newChildren[child].Suffix(value);
                return(new BitmappedTrieBranch <A>(Count + 1, depth, newChildren));
            }

            // TODO: this is wrong? create all necessary levels
            var sibiling = new A[16];

            sibiling[0] = value;
            var parent = new IBitmappedTrie <A> [16];

            parent[0] = this;
            parent[1] = new BitmappedTrieLeaf <A>(1, sibiling);
            return(new BitmappedTrieBranch <A>(Count + 1, depth + 1, parent));
        }