Beispiel #1
0
        /// <summary>
        /// Union algorithm:
        /// 1. Add both sequences of items to a newly created sequence
        /// 2. Sort the items based on document position
        /// 3. Renumber positions in this new unionized sequence
        /// </summary>
        internal NodeSequence Union(ProcessingContext context, NodeSequence otherSeq)
        {
            NodeSequence seq = context.CreateSequence();

            SortedBuffer <QueryNode, QueryNodeComparer> buff = new SortedBuffer <QueryNode, QueryNodeComparer>(staticQueryNodeComparerInstance);

            for (int i = 0; i < this.count; ++i)
            {
                buff.Add(this.items[i].Node);
            }

            for (int i = 0; i < otherSeq.count; ++i)
            {
                buff.Add(otherSeq.items[i].Node);
            }

            for (int i = 0; i < buff.Count; ++i)
            {
                seq.Add(buff[i]);
            }

            seq.RenumberItems();
            return(seq);

            /*
             * // PERF, [....], I think we can do the merge ourselves and avoid the sort.
             * //               Need to verify that the sequences are always in document order.
             * for(int i = 0; i < this.count; ++i)
             * {
             *  seq.AddCopy(ref this.items[i]);
             * }
             *
             * for(int i = 0; i < otherSeq.count; ++i)
             * {
             *  seq.AddCopy(ref otherSeq.items[i]);
             * }
             *
             * seq.SortNodes();
             * seq.RemoveDuplicates();
             *
             * return seq;
             */
        }
        internal NodeSequence Union(ProcessingContext context, NodeSequence otherSeq)
        {
            NodeSequence sequence = context.CreateSequence();
            SortedBuffer <QueryNode, QueryNodeComparer> buffer = new SortedBuffer <QueryNode, QueryNodeComparer>(staticQueryNodeComparerInstance);

            for (int i = 0; i < this.count; i++)
            {
                buffer.Add(this.items[i].Node);
            }
            for (int j = 0; j < otherSeq.count; j++)
            {
                buffer.Add(otherSeq.items[j].Node);
            }
            for (int k = 0; k < buffer.Count; k++)
            {
                sequence.Add(buffer[k]);
            }
            sequence.RenumberItems();
            return(sequence);
        }
 internal TrieSegment(string sourceSegment, int offset, int length)
 {
     this.SetSegmentString(sourceSegment, offset, length);
     this.children = new SortedBuffer <TrieSegment, TrieSegmentComparer>(SegComparer);
 }
 internal TrieSegment(char firstChar, string segmentTail)
 {
     this.SetSegment(firstChar, segmentTail);
     this.children = new SortedBuffer <TrieSegment, TrieSegmentComparer>(SegComparer);
 }
 private void CreateEmptyTables()
 {
     this.filterTypeMappings = new Dictionary <System.Type, System.Type>();
     this.filters            = new Dictionary <MessageFilter, TFilterData>();
     this.tables             = new SortedBuffer <FilterTableEntry <TFilterData>, TableEntryComparer <TFilterData> >(MessageFilterTable <TFilterData> .staticComparerInstance);
 }
 void CreateEmptyTables()
 {
     this.filterTypeMappings = new Dictionary <Type, Type>();
     this.filters            = new Dictionary <MessageFilter, TFilterData>();
     this.tables             = new SortedBuffer <FilterTableEntry, TableEntryComparer>(staticComparerInstance);
 }
 internal TrieSegment(string sourceSegment, int offset, int length)
 {
     Fx.Assert(null != sourceSegment && length > 0, "");
     this.SetSegmentString(sourceSegment, offset, length);
     this.children = new SortedBuffer <TrieSegment, TrieSegmentComparer>(SegComparer);
 }