Inc() public static method

Plus a GLOBCNT by 1.
public static Inc ( GLOBCNT g ) : GLOBCNT
g GLOBCNT A GLOBCNT instance.
return GLOBCNT
Exemplo n.º 1
0
        /// <summary>
        /// Get GLOBCNTs from a GLOBCNTRange list.
        /// </summary>
        /// <param name="rangeList">A GLOBCNTRange list.</param>
        /// <returns>A GLOBCNT list corresponding to the GLOBCNTRange list.</returns>
        public static List <GLOBCNT> GetGLOBCNTList(List <GLOBCNTRange> rangeList)
        {
            List <GLOBCNT> cnts = new List <GLOBCNT>();

            foreach (GLOBCNTRange range in rangeList)
            {
                GLOBCNT tmp = range.StartGLOBCNT;
                cnts.Add(tmp);
                tmp = GLOBCNT.Inc(tmp);
                while (tmp <= range.EndGLOBCNT)
                {
                    cnts.Add(tmp);
                    tmp = GLOBCNT.Inc(tmp);
                }
            }

            return(cnts);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Compresses GLOBCNTRanges in the GLOBCNTRange list to as a bitmask command.
        /// </summary>
        /// <param name="startIndex">The start index of the GLOBCNTRange in the GLOBCNTRange list to compress.</param>
        /// <param name="endIndex">The end index of the GLOBCNTRange in the GLOBCNTRange list to compress.</param>
        /// <returns>The count of bytes have been wrote to the stream.</returns>
        private int CompressBitmask(int startIndex, int endIndex)
        {
            this.Verify(startIndex <= endIndex);
            List <GLOBCNT> list = GetGLOBCNTList(
                this.globcntRangeList.GetRange(startIndex, endIndex - startIndex + 1));
            byte    bitmask    = 0;
            GLOBCNT tmp        = list[0];
            byte    startValue = tmp.Byte6;

            tmp = GLOBCNT.Inc(tmp);
            this.Verify(list.Count < 10);
            for (int i = 0; i < 9; i++)
            {
                if (list.Contains(tmp))
                {
                    bitmask |= checked ((byte)(1 << i));
                }

                tmp = GLOBCNT.Inc(tmp);
            }

            return(this.Bitmask(this.stream, startValue, bitmask));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get GLOBCNTRanges from a GLOBCNT list.
        /// </summary>
        /// <param name="globcntList">A GLOBCNT list.</param>
        /// <returns>A GLOBCNTRange list corresponding to the GLOBCNT list.</returns>
        public static List <GLOBCNTRange> GetGLOBCNTRange(List <GLOBCNT> globcntList)
        {
            // _REPLID = id;
            int                 i, j;
            List <GLOBCNT>      list             = new List <GLOBCNT>();
            List <GLOBCNTRange> globSETRangeList = new List <GLOBCNTRange>();

            // Do a copy.
            for (i = 0; i < globcntList.Count; i++)
            {
                list.Add(globcntList[i]);
            }

            // Remove all the duplicate GLOBCNT values.
            for (i = 0; i < list.Count - 1; i++)
            {
                j = i + 1;
                while (j < list.Count)
                {
                    if (list[i] == list[j])
                    {
                        list.RemoveAt(j);
                        continue;
                    }
                    else
                    {
                        j++;
                    }
                }
            }

            // Sort GLOBCNT.
            list.Sort(new Comparison <GLOBCNT>(delegate(GLOBCNT c1, GLOBCNT c2)
            {
                if (c1 < c2)
                {
                    return(-1);
                }

                if (c1 > c2)
                {
                    return(1);
                }

                return(0);
            }));

            // Make a GLOBCNTRange list.
            i = 0;
            while (i < list.Count)
            {
                GLOBCNT start = list[i];
                GLOBCNT end   = start;
                GLOBCNT next  = end;
                j = i + 1;
                while (j < list.Count)
                {
                    end  = next;
                    next = GLOBCNT.Inc(end);
                    if (list[j] == next)
                    {
                        list.RemoveAt(j);
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }

                globSETRangeList.Add(new GLOBCNTRange(start, end));
                i++;
            }

            return(globSETRangeList);
        }