Alloc() public method

public Alloc ( int size ) : int
size int
return int
 public HyphenationTree()
 {
     stoplist = new Dictionary<string,List<object>>(23);    // usually a small table
     classmap = new TernaryTree();
     vspace = new ByteVector();
     vspace.Alloc(1);    // this reserves index 0, which we don't use
 }
Example #2
0
 public HyphenationTree()
 {
     stoplist = new Dictionary <string, List <object> >(23);    // usually a small table
     classmap = new TernaryTree();
     vspace   = new ByteVector();
     vspace.Alloc(1);    // this reserves index 0, which we don't use
 }
 public HyphenationTree()
 {
     Stoplist = new Hashtable(23); // usually a small table
     Classmap = new TernaryTree();
     Vspace   = new ByteVector();
     Vspace.Alloc(1); // this reserves index 0, which we don't use
 }
Example #4
0
 /**
 * Packs the values by storing them in 4 bits, two values into a byte
 * Values range is from 0 to 9. We use zero as terminator,
 * so we'll add 1 to the value.
 * @param values a string of digits from '0' to '9' representing the
 * interletter values.
 * @return the index into the vspace array where the packed values
 * are stored.
 */
 protected int PackValues(String values) {
     int i, n = values.Length;
     int m = (n & 1) == 1 ? (n >> 1) + 2 : (n >> 1) + 1;
     int offset = vspace.Alloc(m);
     byte[] va = vspace.Arr;
     for (i = 0; i < n; i++) {
         int j = i >> 1;
         byte v = (byte)((values[i] - '0' + 1) & 0x0f);
         if ((i & 1) == 1) {
             va[j + offset] = (byte)(va[j + offset] | v);
         } else {
             va[j + offset] = (byte)(v << 4);    // big endian
         }
     }
     va[m - 1 + offset] = 0;    // terminator
     return offset;
 }
        /// <summary>
        /// Packs the values by storing them in 4 bits, two values into a byte
        /// Values range is from 0 to 9. We use zero as terminator,
        /// so we'll add 1 to the value.
        /// interletter values.
        /// are stored.
        /// </summary>
        /// <param name="values">a string of digits from '0' to '9' representing the</param>
        /// <returns>the index into the vspace array where the packed values</returns>
        protected int PackValues(string values)
        {
            int i, n = values.Length;
            var m      = (n & 1) == 1 ? (n >> 1) + 2 : (n >> 1) + 1;
            var offset = Vspace.Alloc(m);
            var va     = Vspace.Arr;

            for (i = 0; i < n; i++)
            {
                var j = i >> 1;
                var v = (byte)((values[i] - '0' + 1) & 0x0f);
                if ((i & 1) == 1)
                {
                    va[j + offset] = (byte)(va[j + offset] | v);
                }
                else
                {
                    va[j + offset] = (byte)(v << 4); // big endian
                }
            }
            va[m - 1 + offset] = 0; // terminator
            return(offset);
        }