Exemple #1
0
            /// <summary>
            /// A method that uses a binary search based on custom ComparatorByItem
            /// that return the index of the searched Node if founded, otherwise a negative number
            /// </summary>
            /// <param name="node">The FPNode looking index for</param>
            /// <returns>the index of the founded node</returns>
            public int GetIndex(FPNode node)
            {
                HTrecord test = new HTrecord();

                test.Item = node.Item;
                return(Array.BinarySearch(HTarray, test, new ComparatorByItem()));
            }
Exemple #2
0
 /// <summary>
 /// Add to header table an entry with the specified value and frequency
 /// </summary>
 /// <param name="item">the value of the item to insert</param>
 /// <param name="freq">the frequency of the item to insert</param>
 public void addRecord(int item, int freq)
 {
     HTarray[position]      = new HTrecord();
     HTarray[position].Freq = freq;
     HTarray[position].Item = item;
     HTarray[position].Head = default(FPNode);
     HTarray[position].Tail = default(FPNode);
     position++;
     if (position == HTarray.Length)
     {
         Array.Sort(HTarray, new ComparatorByItem());
     }
 }