natix.CompactDS.CompressedInvertedIndex.Add C# (CSharp) Method

Add() public method

Adds a posting list to the index. Returns the corresponding symbol
public Add ( IEnumerable sortedlist ) : int
sortedlist IEnumerable Sortedlist.
return int
        public int Add(IEnumerable<int> sortedlist)
        {
            long prev = -1;
            var pos = 0;
            var count = 0;

            foreach (var item in sortedlist) {
                if (prev == -1) {
                    pos = this.lstream.Add (item);
                } else {
                    this.lstream.Add (item - prev);
                }
                prev = item;
                ++count;
            }

            this.offsets.Add (pos);
            this.lengths.Add (count);
            this.numberOfItems += count;
            return this.offsets.Count - 1;
        }

Same methods

CompressedInvertedIndex::Add ( IEnumerable sortedlist ) : int

Usage Example

Ejemplo n.º 1
0
 public static CompressedInvertedIndex Build(InvertedIndex invindex)
 {
     var cii = new CompressedInvertedIndex ();
     for (int s = 0; s < invindex.Count; ++s) {
         cii.Add (invindex [s]);
     }
     return cii;
 }