private DString wrap(string s)
        {
            // Presence is a tallymark-like system for counting character occurrences in a string, regardless of position
            ulong presence = 0L;

            Dictionary <char, CCount> counts = CCount.Decompose(s);

            foreach (CCount cbits in bits)
            {
                ushort marked = 0;
                CCount c;
                if (counts.TryGetValue(cbits.Chr, out c))
                {
                    marked = c.Count;
                }

                ushort upTo = cbits.Count;
                for (ushort i = 0; i < upTo; i++)
                {
                    presence = presence << 1;
                    if (marked > 0)
                    {
                        presence |= 1;
                        marked--;
                    }
                }
            }
            return(new DString(s, presence));
        }
Exemple #2
0
 public void Update(string str)
 {
     if (str.Length == 0)
     {
         return;
     }
     foreach (CCount cc in CCount.Decompose(str).Values)
     {
         List <uint> vals;
         if (!counts.TryGetValue(cc.Chr, out vals))
         {
             vals = new List <uint>();
             counts.Add(cc.Chr, vals);
         }
         while (vals.Count < cc.Count)
         {
             // Insert zeros until the array of counts can support the value we want to insert
             vals.Add(0);
         }
         // We can't have a count of 0, so count positions need to be offset by 1
         vals[cc.Count - 1]++;
     }
     total++;
 }