A Cell is a portion of a Trie.
Exemple #1
0
 /// <summary>
 /// Construct a <see cref="Row"/> object from input carried in via the given input stream.
 /// </summary>
 /// <param name="@is">the input stream</param>
 /// <exception cref="IOException">if an I/O error occurs</exception>
 public Row(IDataInput @is)
 {
     for (int i = @is.ReadInt(); i > 0; i--)
     {
         char ch = @is.ReadChar();
         Cell c = new Cell();
         c.cmd = @is.ReadInt();
         c.cnt = @is.ReadInt();
         c.@ref = @is.ReadInt();
         c.skip = @is.ReadInt();
         cells[ch] = c;
     }
 }
Exemple #2
0
 /// <summary>
 /// Set the command in the <see cref="Cell"/> of the given <see cref="char"/> to the given <see cref="int"/>.
 /// </summary>
 /// <param name="way">the <see cref="char"/> defining the <see cref="Cell"/></param>
 /// <param name="cmd">the new command</param>
 public void SetCmd(char way, int cmd)
 {
     Cell c = At(way);
     if (c == null)
     {
         c = new Cell();
         c.cmd = cmd;
         cells[way] = c;
     }
     else
     {
         c.cmd = cmd;
     }
     c.cnt = (cmd >= 0) ? 1 : 0;
 }
Exemple #3
0
 /// <summary>
 /// Set the reference to the next row in the <see cref="Cell"/> of the given <see cref="char"/> to the
 /// given <see cref="int"/>.
 /// </summary>
 /// <param name="way">the <see cref="char"/> defining the <see cref="Cell"/></param>
 /// <param name="ref">The new ref value</param>
 public void SetRef(char way, int @ref)
 {
     Cell c = At(way);
     if (c == null)
     {
         c = new Cell();
         c.@ref = @ref;
         cells[way] = c;
     }
     else
     {
         c.@ref = @ref;
     }
 }
        /// <summary>
        /// Merge the given <see cref="Cell"/>s and return the resulting <see cref="Cell"/>.
        /// </summary>
        /// <param name="m">the master <see cref="Cell"/></param>
        /// <param name="e">the existing <see cref="Cell"/></param>
        /// <returns>the resulting <see cref="Cell"/>, or <c>null</c> if the operation cannot be realized</returns>
        public virtual Cell Merge(Cell m, Cell e)
        {
            Cell n = new Cell();

            if (m.skip != e.skip)
            {
                return null;
            }

            if (m.cmd >= 0)
            {
                if (e.cmd >= 0)
                {
                    if (m.cmd == e.cmd)
                    {
                        n.cmd = m.cmd;
                    }
                    else
                    {
                        return null;
                    }
                }
                else
                {
                    n.cmd = m.cmd;
                }
            }
            else
            {
                n.cmd = e.cmd;
            }
            if (m.@ref >= 0)
            {
                if (e.@ref >= 0)
                {
                    if (m.@ref == e.@ref)
                    {
                        if (m.skip == e.skip)
                        {
                            n.@ref = m.@ref;
                        }
                        else
                        {
                            return null;
                        }
                    }
                    else
                    {
                        return null;
                    }
                }
                else
                {
                    n.@ref = m.@ref;
                }
            }
            else
            {
                n.@ref = e.@ref;
            }
            n.cnt = m.cnt + e.cnt;
            n.skip = m.skip;
            return n;
        }