Example #1
0
 public BoolArray(BoolArray array)
 {
     this.ordered = array.ordered;
     length       = array.length;
     items        = new bool[length];
     JavaSystem.Arraycopy(array.items, 0, items, 0, length);
 }
Example #2
0
 public static bool[] Concat(bool[] array, int alen, bool[] other, int blen)
 {
     bool[] ret = new bool[alen + blen];
     JavaSystem.Arraycopy(array, 0, ret, 0, alen);
     JavaSystem.Arraycopy(other, 0, ret, alen, blen);
     return(ret);
 }
Example #3
0
 public static long[] Concat(long[] array, int alen, long[] other, int blen)
 {
     long[] ret = new long[alen + blen];
     JavaSystem.Arraycopy(array, 0, ret, 0, alen);
     JavaSystem.Arraycopy(other, 0, ret, alen, blen);
     return(ret);
 }
Example #4
0
 public static sbyte[] Concat(sbyte[] array, int alen, sbyte[] other, int blen)
 {
     sbyte[] ret = new sbyte[alen + blen];
     JavaSystem.Arraycopy(array, 0, ret, 0, alen);
     JavaSystem.Arraycopy(other, 0, ret, alen, blen);
     return(ret);
 }
Example #5
0
        public override int[] ToGray(int[] buffer, int w, int h)
        {
            int size = w * h;

            int[] newResult = new int[size];
            JavaSystem.Arraycopy(buffer, 0, newResult, 0, size);
            int alpha = 0xFF << 24;

            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    int idx   = w * i + j;
                    int color = newResult[idx];
                    if (color != 0x00FFFFFF)
                    {
                        int red   = ((color & 0x00FF0000) >> 16);
                        int green = ((color & 0x0000FF00) >> 8);
                        int blue  = color & 0x000000FF;
                        color          = (red + green + blue) / 3;
                        color          = alpha | (color << 16) | (color << 8) | color;
                        newResult[idx] = color;
                    }
                }
            }
            return(newResult);
        }
Example #6
0
 private void EnsureCapacity()
 {
     if (size >= threshold)
     {
         Entry[] oldTable     = valuesTable;
         int     newCapacity  = oldTable.Length * 2 + 1;
         Entry[] newMapTable  = new Entry[newCapacity];
         Entry[] newListTable = new Entry[newCapacity];
         threshold = (int)(newCapacity * loadFactor);
         JavaSystem.Arraycopy(oldTable, 0, newListTable, 0, size);
         for (int i = 0; i < size; i++)
         {
             Entry old   = oldTable[i];
             int   index = (old.hashCode & 0x7FFFFFFF) % newCapacity;
             Entry e     = old;
             old                   = old.next;
             e.next                = newMapTable[index];
             newMapTable[index]    = e;
             newListTable[i].index = i;
         }
         keysTable   = newMapTable;
         valuesTable = newListTable;
         removed     = 0;
     }
 }
Example #7
0
        public void RemoveRange(int start, int end)
        {
            if (end >= length)
            {
                throw new LSysException("end can't be >= length: " + end + " >= " + length);
            }
            if (start > end)
            {
                throw new LSysException("start can't be > end: " + start + " > " + end);
            }
            sbyte[] bytebuffer = this.bytebuffer;
            int     count      = end - start + 1;

            if (ordered)
            {
                JavaSystem.Arraycopy(bytebuffer, start + count, bytebuffer, start, length - (start + count));
            }
            else
            {
                int lastIndex = this.length - 1;
                for (int i = 0; i < count; i++)
                {
                    bytebuffer[start + i] = bytebuffer[lastIndex - i];
                }
            }
            length -= count;
        }
Example #8
0
 public IntArray(IntArray array)
 {
     this.ordered = array.ordered;
     length       = array.length;
     items        = new int[length];
     JavaSystem.Arraycopy(array.items, 0, items, 0, length);
 }
Example #9
0
 public static float[] Concat(float[] array, int alen, float[] other, int blen)
 {
     float[] ret = new float[alen + blen];
     JavaSystem.Arraycopy(array, 0, ret, 0, alen);
     JavaSystem.Arraycopy(other, 0, ret, alen, blen);
     return(ret);
 }
Example #10
0
        public void setStreamParameters(byte[] pps, byte[] sps)
        {
            this.pps = pps;
            this.sps = sps;

            // A STAP-A NAL (NAL type 24) containing the sps and pps of the stream
            if (pps != null && sps != null)
            {
                // STAP-A NAL header + NALU 1 (SPS) size + NALU 2 (PPS) size = 5 bytes
                stapa = new byte[sps.Length + pps.Length + 5];

                // STAP-A NAL header is 24
                stapa[0] = 24;

                // Write NALU 1 size into the array (NALU 1 is the SPS).
                stapa[1] = (byte)(sps.Length >> 8);
                stapa[2] = (byte)(sps.Length & 0xFF);

                // Write NALU 2 size into the array (NALU 2 is the PPS).
                stapa[sps.Length + 3] = (byte)(pps.Length >> 8);
                stapa[sps.Length + 4] = (byte)(pps.Length & 0xFF);

                // Write NALU 1 into the array, then write NALU 2 into the array.
                JavaSystem.Arraycopy(sps, 0, stapa, 3, sps.Length);
                JavaSystem.Arraycopy(pps, 0, stapa, 5 + sps.Length, pps.Length);
            }
        }
Example #11
0
        public void AddPolyPoint(float x, float y)
        {
            for (int i = 0; i < numPoints; i++)
            {
                if ((pointsX[i] == x) && (pointsY[i] == y))
                {
                    y      += offset;
                    offset += EPSILON;
                }
            }

            if (numPoints == pointsX.Length)
            {
                float[] af = new float[numPoints * 2];
                JavaSystem.Arraycopy(pointsX, 0, af, 0, numPoints);
                pointsX = af;
                af      = new float[numPoints * 2];
                JavaSystem.Arraycopy(pointsY, 0, af, 0, numPoints);
                pointsY = af;
            }

            pointsX[numPoints] = x;
            pointsY[numPoints] = y;
            numPoints++;
        }
Example #12
0
        public StrBuilder Delete(int start, int end)
        {
            if (this._values == null)
            {
                return(this);
            }
            if (start < 0)
            {
                start = 0;
            }
            if (end >= this._currentIndex)
            {
                this._currentIndex = start;
                this._dirty        = true;
                return(this);
            }
            else if (end < 0)
            {
                end = 0;
            }
            int len = end - start;

            if (len > 0)
            {
                JavaSystem.Arraycopy(_values, start + len, _values, start, this._currentIndex - end);
                this._currentIndex -= len;
                this._dirty         = true;
            }
            else if (len < 0)
            {
                throw new LSysException("index out of range: " + this._currentIndex);
            }
            return(this);
        }
Example #13
0
 public LongArray(LongArray array)
 {
     this.ordered = array.ordered;
     length       = array.length;
     items        = new long[length];
     JavaSystem.Arraycopy(array.items, 0, items, 0, length);
 }
Example #14
0
 public FloatArray(FloatArray array)
 {
     this.ordered = array.ordered;
     length       = array.length;
     items        = new float[length];
     JavaSystem.Arraycopy(array.items, 0, items, 0, length);
 }
Example #15
0
 public CharArray(CharArray array)
 {
     this.ordered = array.ordered;
     length       = array.length;
     items        = new char[length];
     JavaSystem.Arraycopy(array.items, 0, items, 0, length);
 }
Example #16
0
 public static char[] Concat(char[] array, int alen, char[] other, int blen)
 {
     char[] ret = new char[alen + blen];
     JavaSystem.Arraycopy(array, 0, ret, 0, alen);
     JavaSystem.Arraycopy(other, 0, ret, alen, blen);
     return(ret);
 }
Example #17
0
        public void RemoveRange(int start, int end)
        {
            if (end >= length)
            {
                throw new LSysException("end can't be >= length: " + end + " >= " + length);
            }
            if (start > end)
            {
                throw new LSysException("start can't be > end: " + start + " > " + end);
            }
            bool[] items = this.items;
            int    count = end - start + 1;

            if (ordered)
            {
                JavaSystem.Arraycopy(items, start + count, items, start, length - (start + count));
            }
            else
            {
                int lastIndex = this.length - 1;
                for (int i = 0; i < count; i++)
                {
                    items[start + i] = items[lastIndex - i];
                }
            }
            length -= count;
        }
Example #18
0
 protected sbyte[] Relength(int newlength)
 {
     sbyte[] newItems   = new sbyte[newlength];
     sbyte[] bytebuffer = this.bytebuffer;
     JavaSystem.Arraycopy(bytebuffer, 0, newItems, 0, MathUtils.Min(length, newItems.Length));
     this.bytebuffer = newItems;
     return(newItems);
 }
Example #19
0
 protected bool[] Relength(int newlength)
 {
     bool[] newItems = new bool[newlength];
     bool[] items    = this.items;
     JavaSystem.Arraycopy(items, 0, newItems, 0, MathUtils.Min(length, newItems.Length));
     this.items = newItems;
     return(newItems);
 }
Example #20
0
 public UIntArray(UIntArray array, UIntMode mode, bool little)
 {
     this.uintmode     = mode;
     this.littleEndian = little;
     this.ordered      = array.ordered;
     length            = array.length;
     bytebuffer        = new sbyte[length];
     JavaSystem.Arraycopy(array.bytebuffer, 0, bytebuffer, 0, length);
 }
Example #21
0
 public override void Rot(float[] mat, float[] vecs, int offset, int numVecs,
                          int stride)
 {
     for (int i = 0; i < numVecs; i++)
     {
         float[] vecPtr = new float[stride];
         JavaSystem.Arraycopy(vecs, offset, vecPtr, 0, stride);
         Rot(mat, vecPtr);
     }
 }
Example #22
0
        public ARC4(sbyte[] key)
        {
            this.state = new sbyte[256];
            int length = MathUtils.Min(256, key.Length);

            sbyte[] keyCopy = new sbyte[length];
            JavaSystem.Arraycopy(key, 0, keyCopy, 0, length);
            this.key = keyCopy;
            Reset();
        }
Example #23
0
 public void Write(sbyte[] buffer, int offset, int length)
 {
     if (length == 0)
     {
         return;
     }
     EnsureCapacity(length);
     JavaSystem.Arraycopy(buffer, offset, data, position, length);
     position += length;
 }
Example #24
0
 public int Read(sbyte[] buffer, int offset, int length)
 {
     if (length == 0)
     {
         return(0);
     }
     CheckAvailable(length);
     JavaSystem.Arraycopy(data, position, buffer, offset, length);
     position += length;
     return(length);
 }
Example #25
0
        public void AddAll(bool[] array, int offset, int len)
        {
            bool[] items        = this.items;
            int    lengthNeeded = this.length + len;

            if (lengthNeeded > items.Length)
            {
                items = Relength(MathUtils.Max(8, (int)(lengthNeeded * 1.75f)));
            }
            JavaSystem.Arraycopy(array, offset, items, this.length, len);
            this.length += len;
        }
Example #26
0
        public void AddAll(long[] array, int offset, int length)
        {
            long[] items        = this.items;
            int    lengthNeeded = length + length;

            if (lengthNeeded > items.Length)
            {
                items = Relength(MathUtils.Max(8, (int)(lengthNeeded * 1.75f)));
            }
            JavaSystem.Arraycopy(array, offset, items, length, length);
            length += length;
        }
Example #27
0
        public void AddAll(sbyte[] array, int offset, int length)
        {
            sbyte[] bytebuffer   = this.bytebuffer;
            int     lengthNeeded = length + length;

            if (lengthNeeded > bytebuffer.Length)
            {
                bytebuffer = Relength(MathUtils.Max(8, (int)(lengthNeeded * 1.75f)));
            }
            JavaSystem.Arraycopy(array, offset, bytebuffer, length, length);
            length += length;
        }
Example #28
0
        private Entry RemoveList(int index)
        {
            Entry e        = valuesTable[index];
            int   numMoved = size - index - 1;

            if (numMoved > 0)
            {
                JavaSystem.Arraycopy(valuesTable, index + 1, valuesTable, index, numMoved);
            }
            valuesTable[--size] = null;
            removed++;
            return(e);
        }
Example #29
0
 public void SetLength(int length)
 {
     if (length != data.Length)
     {
         sbyte[] oldData = data;
         data = new sbyte[length];
         JavaSystem.Arraycopy(oldData, 0, data, 0, MathUtils.Min(oldData.Length, length));
         if (position > length)
         {
             position = length;
         }
     }
 }
Example #30
0
 private void UpdateIndex(int index, int length)
 {
     EnsureCapacity(MathUtils.Max(this._currentIndex, index) + length);
     if (index < this._currentIndex)
     {
         JavaSystem.Arraycopy(this._values, index, this._values, index + length, this._currentIndex - index);
     }
     else if (index > this._currentIndex)
     {
         CollectionUtils.Fill(this._values, this._currentIndex, index, ' ');
     }
     this._dirty = true;
 }