At() private method

private At ( char index ) : Cell
index char
return Cell
Example #1
0
        /// <summary>
        /// Merge the given rows and return the resulting <see cref="Row"/>.
        /// </summary>
        /// <param name="master">the master <see cref="Row"/></param>
        /// <param name="existing">the existing <see cref="Row"/></param>
        /// <returns>the resulting <see cref="Row"/>, or <c>null</c> if the operation cannot be realized</returns>
        public Row Merge(Row master, Row existing)
        {
            var i = master.cells.Keys.GetEnumerator();
            Row n = new Row();

            for (; i.MoveNext();)
            {
                char ch = i.Current;
                // XXX also must handle Cnt and Skip !!
                Cell a = master.cells.ContainsKey(ch) ? master.cells[ch] : null;
                Cell b = existing.cells.ContainsKey(ch) ? existing.cells[ch] : null;

                Cell s = (b == null) ? new Cell(a) : Merge(a, b);
                if (s == null)
                {
                    return(null);
                }
                n.cells[ch] = s;
            }
            i = existing.cells.Keys.GetEnumerator();
            for (; i.MoveNext();)
            {
                char ch = i.Current;
                if (master.At(ch) != null)
                {
                    continue;
                }
                n.cells[ch] = existing.At(ch);
            }
            return(n);
        }
Example #2
0
        /// <summary>
        /// Merge the given rows and return the resulting <see cref="Row"/>.
        /// </summary>
        /// <param name="master">the master <see cref="Row"/></param>
        /// <param name="existing">the existing <see cref="Row"/></param>
        /// <returns>the resulting <see cref="Row"/>, or <c>null</c> if the operation cannot be realized</returns>
        public Row Merge(Row master, Row existing)
        {
            Row n = new Row();

            foreach (char ch in master.cells.Keys)
            {
                // XXX also must handle Cnt and Skip !!
                master.cells.TryGetValue(ch, out Cell a);

                Cell s = !existing.cells.TryGetValue(ch, out Cell b) || (b is null) ? new Cell(a) : Merge(a, b);
                if (s is null)
                {
                    return(null);
                }
                n.cells[ch] = s;
            }
            foreach (char ch in existing.cells.Keys)
            {
                if (master.At(ch) != null)
                {
                    continue;
                }
                n.cells[ch] = existing.At(ch);
            }
            return(n);
        }
Example #3
0
        /// <summary>
        /// Merge the given rows and return the resulting <see cref="Row"/>.
        /// </summary>
        /// <param name="master">the master <see cref="Row"/></param>
        /// <param name="existing">the existing <see cref="Row"/></param>
        /// <returns>the resulting <see cref="Row"/>, or <c>null</c> if the operation cannot be realized</returns>
        public Row Merge(Row master, Row existing)
        {
            Row n = new Row();

            foreach (char ch in master.cells.Keys)
            {
                // XXX also must handle Cnt and Skip !!
                Cell a = master.cells.ContainsKey(ch) ? master.cells[ch] : null;
                Cell b = existing.cells.ContainsKey(ch) ? existing.cells[ch] : null;

                Cell s = (b == null) ? new Cell(a) : Merge(a, b);
                if (s == null)
                {
                    return(null);
                }
                n.cells[ch] = s;
            }
            foreach (char ch in existing.cells.Keys)
            {
                if (master.At(ch) != null)
                {
                    continue;
                }
                n.cells[ch] = existing.At(ch);
            }
            return(n);
        }
Example #4
0
        /// <summary>
        /// Return the element that is stored in a cell associated with the given key.
        /// </summary>
        /// <param name="key">the key</param>
        /// <returns>the associated element</returns>
        public virtual string GetFully(string key)
        {
            Row     now = GetRow(root);
            int     w;
            Cell    c;
            int     cmd = -1;
            StrEnum e   = new StrEnum(key, forward);
            char    ch;

            //char aux; // LUCENENET: IDE0059: Remove unnecessary value assignment

            for (int i = 0; i < key.Length;)
            {
                ch = e.Next();
                i++;

                c = now.At(ch);
                if (c == null)
                {
                    return(null);
                }

                cmd = c.cmd;

                for (int skip = c.skip; skip > 0; skip--)
                {
                    if (i < key.Length)
                    {
                        /*aux =*/ e.Next(); // LUCENENET: IDE0059: Remove unnecessary value assignment
                    }
                    else
                    {
                        return(null);
                    }
                    i++;
                }

                w = now.GetRef(ch);
                if (w >= 0)
                {
                    now = GetRow(w);
                }
                else if (i < key.Length)
                {
                    return(null);
                }
            }
            return((cmd == -1) ? null : cmds[cmd]);
        }
Example #5
0
        /// <summary>
        /// Return the element that is stored in a cell associated with the given key.
        /// </summary>
        /// <param name="key">the key</param>
        /// <returns>the associated element</returns>
        public virtual string GetFully(string key)
        {
            Row     now = GetRow(root);
            int     w;
            Cell    c;
            int     cmd = -1;
            StrEnum e   = new StrEnum(key, forward);
            char    ch;
            char    aux;

            for (int i = 0; i < key.Length;)
            {
                ch = e.Next();
                i++;

                c = now.At(ch);
                if (c == null)
                {
                    return(null);
                }

                cmd = c.cmd;

                for (int skip = c.skip; skip > 0; skip--)
                {
                    if (i < key.Length)
                    {
                        aux = e.Next();
                    }
                    else
                    {
                        return(null);
                    }
                    i++;
                }

                w = now.GetRef(ch);
                if (w >= 0)
                {
                    now = GetRow(w);
                }
                else if (i < key.Length)
                {
                    return(null);
                }
            }
            return((cmd == -1) ? null : cmds[cmd]);
        }
Example #6
0
 /// <summary>
 /// Constructor for the <see cref="Remap"/> object
 /// </summary>
 /// <param name="old">Description of the Parameter</param>
 /// <param name="remap">Description of the Parameter</param>
 public Remap(Row old, int[] remap)
     : base()
 {
     foreach (char ch in old.cells.Keys)
     {
         Cell c = old.At(ch);
         Cell nc;
         if (c.@ref >= 0)
         {
             nc      = new Cell(c);
             nc.@ref = remap[nc.@ref];
         }
         else
         {
             nc = new Cell(c);
         }
         cells[ch] = nc;
     }
 }
Example #7
0
            /**
             * Constructor for the <see cref="Remap"/> object
             *
             * @param old Description of the Parameter
             * @param remap Description of the Parameter
             */
            public Remap(Row old, int[] remap)
                : base()
            {
                var i = old.cells.Keys.GetEnumerator();

                for (; i.MoveNext();)
                {
                    char ch = i.Current;
                    Cell c  = old.At(ch);
                    Cell nc;
                    if (c.@ref >= 0)
                    {
                        nc      = new Cell(c);
                        nc.@ref = remap[nc.@ref];
                    }
                    else
                    {
                        nc = new Cell(c);
                    }
                    cells[ch] = nc;
                }
            }
Example #8
0
        /// <summary>
        /// Merge the given rows and return the resulting <see cref="Row"/>.
        /// </summary>
        /// <param name="master">the master <see cref="Row"/></param>
        /// <param name="existing">the existing <see cref="Row"/></param>
        /// <returns>the resulting <see cref="Row"/>, or <c>null</c> if the operation cannot be realized</returns>
        public Row Merge(Row master, Row existing)
        {
            var i = master.cells.Keys.GetEnumerator();
            Row n = new Row();
            for (; i.MoveNext();)
            {
                char ch = i.Current;
                // XXX also must handle Cnt and Skip !!
                Cell a = master.cells.ContainsKey(ch) ? master.cells[ch] : null;
                Cell b = existing.cells.ContainsKey(ch) ? existing.cells[ch] : null;

                Cell s = (b == null) ? new Cell(a) : Merge(a, b);
                if (s == null)
                {
                    return null;
                }
                n.cells[ch] = s;
            }
            i = existing.cells.Keys.GetEnumerator();
            for (; i.MoveNext();)
            {
                char ch = i.Current;
                if (master.At(ch) != null)
                {
                    continue;
                }
                n.cells[ch] = existing.At(ch);
            }
            return n;
        }