make() public static method

public static make ( ) : IndexErr
return IndexErr
Beispiel #1
0
        public void eachRange(Range r, Func f)
        {
            int s = r.start(m_size);
            int e = r.end(m_size);
            int n = e - s + 1;

            if (n < 0)
            {
                throw IndexErr.make(r).val;
            }

            if (f.arity() == 1)
            {
                for (int i = s; i <= e; ++i)
                {
                    f.call(m_values[i]);
                }
            }
            else
            {
                for (int i = s; i <= e; ++i)
                {
                    f.call(m_values[i], i);
                }
            }
        }
Beispiel #2
0
        public List removeRange(Range r)
        {
            modify();
            int s = r.start(m_size);
            int e = r.end(m_size);
            int n = e - s + 1;

            if (n < 0)
            {
                throw IndexErr.make(r).val;
            }

            int shift = m_size - s - n;

            if (shift > 0)
            {
                Array.Copy(m_values, s + n, m_values, s, shift);
            }
            m_size -= n;
            for (int i = m_size; i < m_size + n; ++i)
            {
                m_values[i] = null;
            }
            return(this);
        }
Beispiel #3
0
        public Long indexSame(object val, long off)
        {
            if (m_size == 0)
            {
                return(null);
            }
            int start = (int)off;

            if (start < 0)
            {
                start = m_size + start;
            }
            if (start >= m_size)
            {
                throw IndexErr.make(off).val;
            }

            try
            {
                for (int i = start; i < m_size; i++)
                {
                    if (val == m_values[i])
                    {
                        return(Long.valueOf(i));
                    }
                }
                return(null);
            }
            catch (IndexOutOfRangeException)
            {
                throw IndexErr.make(off).val;
            }
        }
Beispiel #4
0
 public object[] copyInto(object[] a, int off, int len)
 {
     try
     {
         Array.Copy(m_values, 0, a, off, len);
         return(a);
     }
     catch (IndexOutOfRangeException)
     {
         throw IndexErr.make().val;
     }
 }
Beispiel #5
0
 public object[] toArray(object[] a, int start, int len)
 {
     try
     {
         Array.Copy(m_values, start, a, 0, len);
         return(a);
     }
     catch (IndexOutOfRangeException)
     {
         throw IndexErr.make().val;
     }
 }
Beispiel #6
0
 public object[] toArray(object[] a)
 {
     try
     {
         Array.Copy(m_values, 0, a, 0, m_size);
         return(a);
     }
     catch (IndexOutOfRangeException)
     {
         throw IndexErr.make().val;
     }
 }
Beispiel #7
0
        public StrBuf removeRange(Range r)
        {
            int s = r.start(sb.Length);
            int e = r.end(sb.Length);
            int n = e - s + 1;

            if (n < 0)
            {
                throw IndexErr.make(r).val;
            }
            sb.Remove(s, n);
            return(this);
        }
Beispiel #8
0
        public long get(long pos)
        {
            long size = getSize();

            if (pos < 0)
            {
                pos = size + pos;
            }
            if (pos < 0 || pos >= size)
            {
                throw IndexErr.make(pos).val;
            }
            return(getByte(pos));
        }
Beispiel #9
0
        public long start(long group)
        {
            // to match java
            if (!matches())
            {
                throw new System.Exception();
            }
            if (group < 0 || group >= m_match.Groups.Count)
            {
                throw IndexErr.make(group).val;
            }

            return(m_match.Groups[(int)group].Index);
        }
Beispiel #10
0
        public static string getRange(string self, Range r)
        {
            int size = self.Length;

            int s = r.start(size);
            int e = r.end(size);

            if (e + 1 < s)
            {
                throw IndexErr.make(r).val;
            }

            return(self.Substring(s, (e - s) + 1));
        }
Beispiel #11
0
        internal long start(long size)
        {
            long x = m_start;

            if (x < 0)
            {
                x = size + x;
            }
            if (x > size)
            {
                throw IndexErr.make(this).val;
            }
            return(x);
        }
Beispiel #12
0
        public string getRange(Range r)
        {
            int size = sb.Length;

            int s = r.start(size);
            int e = r.end(size);

            if (e + 1 < s)
            {
                throw IndexErr.make(r).val;
            }

            return(sb.ToString().Substring(s, (e - s) + 1));
        }
Beispiel #13
0
        //////////////////////////////////////////////////////////////////////////
        // Slice Utils
        //////////////////////////////////////////////////////////////////////////

        internal int start(int size)
        {
            int x = (int)m_start;

            if (x < 0)
            {
                x = size + x;
            }
            if (x > size)
            {
                throw IndexErr.make(this).val;
            }
            return(x);
        }
Beispiel #14
0
 public object get(int i)
 {
     try
     {
         if (i >= m_size)
         {
             throw IndexErr.make("" + i).val;
         }
         return(m_values[i]);
     }
     catch (IndexOutOfRangeException)
     {
         throw IndexErr.make("" + i).val;
     }
 }
Beispiel #15
0
        public StrBuf remove(long index)
        {
            int i = (int)index;

            if (i < 0)
            {
                i = sb.Length + i;
            }
            if (i >= sb.Length)
            {
                throw IndexErr.make(index).val;
            }
            sb.Remove(i, 1);
            return(this);
        }
Beispiel #16
0
        public List insert(long index, object val)
        {
            // modify in insert(int, object)
            int i = (int)index;

            if (i < 0)
            {
                i = m_size + i;
            }
            if (i > m_size)
            {
                throw IndexErr.make(index).val;
            }
            return(insert(i, val));
        }
Beispiel #17
0
        //////////////////////////////////////////////////////////////////////////
        // Modification
        //////////////////////////////////////////////////////////////////////////

        public Buf set(long pos, long b)
        {
            long size = getSize();

            if (pos < 0)
            {
                pos = size + pos;
            }
            if (pos < 0 || pos >= size)
            {
                throw IndexErr.make(pos).val;
            }
            setByte(pos, (int)b);
            return(this);
        }
Beispiel #18
0
        public List insertAll(long index, List list)
        {
            // modify in insertAll(int, List)
            int i = (int)index;

            if (i < 0)
            {
                i = m_size + i;
            }
            if (i > m_size || i < 0)
            {
                throw IndexErr.make(index).val;
            }
            return(insertAll(i, list));
        }
Beispiel #19
0
        public Buf seek(long pos)
        {
            long p    = pos;
            long size = getSize();

            if (p < 0)
            {
                p = size + p;
            }
            if (p < 0 || p > size)
            {
                throw IndexErr.make(pos).val;
            }
            setPos(p);
            return(this);
        }
Beispiel #20
0
        public StrBuf insert(long index, object x)
        {
            string s = (x == null) ? "null" : toStr(x);
            int    i = (int)index;

            if (i < 0)
            {
                i = sb.Length + i;
            }
            if (i > sb.Length)
            {
                throw IndexErr.make(index).val;
            }
            sb.Insert(i, s);
            return(this);
        }
Beispiel #21
0
        public long end(long group)
        {
            // to match java
            if (!matches())
            {
                throw new System.Exception();
            }
            if (group < 0 || group >= m_match.Groups.Count)
            {
                throw IndexErr.make(group).val;
            }

            Group g = m_match.Groups[(int)group];

            return(g.Index + g.Length);
        }
Beispiel #22
0
        //////////////////////////////////////////////////////////////////////////
        // Operators
        //////////////////////////////////////////////////////////////////////////

        public static long get(string self, long index)
        {
            try
            {
                int i = (int)index;
                if (i < 0)
                {
                    i = self.Length + i;
                }
                return(self[i]);
            }
            catch (System.IndexOutOfRangeException)
            {
                throw IndexErr.make(index).val;
            }
        }
Beispiel #23
0
 public long get(long index)
 {
     try
     {
         int i = (int)index;
         if (i < 0)
         {
             i = sb.Length + i;
         }
         return(sb[i]);
     }
     catch (System.ArgumentOutOfRangeException e)
     {
         throw IndexErr.make(e).val;
     }
 }
Beispiel #24
0
        public Long indexr(object val, long off)
        {
            if (m_size == 0)
            {
                return(null);
            }
            int start = (int)off;

            if (start < 0)
            {
                start = m_size + start;
            }
            if (start >= m_size)
            {
                throw IndexErr.make(off).val;
            }

            try
            {
                if (val == null)
                {
                    for (int i = start; i >= 0; --i)
                    {
                        if (m_values[i] == null)
                        {
                            return(Long.valueOf(i));
                        }
                    }
                }
                else
                {
                    for (int i = start; i >= 0; --i)
                    {
                        object obj = m_values[i];
                        if (obj != null && obj.Equals(val))
                        {
                            return(Long.valueOf(i));
                        }
                    }
                }
                return(null);
            }
            catch (IndexOutOfRangeException)
            {
                throw IndexErr.make(off).val;
            }
        }
Beispiel #25
0
 public StrBuf set(long index, long ch)
 {
     try
     {
         int i = (int)index;
         if (i < 0)
         {
             i = sb.Length + i;
         }
         sb[i] = (char)ch;
         return(this);
     }
     catch (System.ArgumentOutOfRangeException e)
     {
         throw IndexErr.make(e).val;
     }
 }
Beispiel #26
0
        internal long end(long size)
        {
            long x = m_end;

            if (x < 0)
            {
                x = size + x;
            }
            if (m_exclusive)
            {
                x--;
            }
            if (x >= size)
            {
                throw IndexErr.make(this).val;
            }
            return(x);
        }
Beispiel #27
0
        internal int end(int size)
        {
            int x = (int)m_end;

            if (x < 0)
            {
                x = size + x;
            }
            if (m_exclusive)
            {
                x--;
            }
            if (x >= size)
            {
                throw IndexErr.make(this).val;
            }
            return(x);
        }
Beispiel #28
0
 public object get(long index)
 {
     try
     {
         int i = (int)index;
         if (i < 0)
         {
             i = m_size + i;
         }
         if (i >= m_size)
         {
             throw IndexErr.make(index).val;
         }
         return(m_values[i]);
     }
     catch (IndexOutOfRangeException)
     {
         throw IndexErr.make(index).val;
     }
 }
Beispiel #29
0
        public Buf getRange(Range range)
        {
            long size = getSize();
            long s    = range.start(size);
            long e    = range.end(size);
            int  n    = (int)(e - s + 1);

            if (n < 0)
            {
                throw IndexErr.make(range).val;
            }

            byte[] slice = new byte[n];
            getBytes(s, slice, 0, n);

            Buf result = new MemBuf(slice, n);

            result.charset(charset());
            return(result);
        }
Beispiel #30
0
        public object removeAt(long index)
        {
            modify();
            int i = (int)index;

            if (i < 0)
            {
                i = m_size + i;
            }
            if (i >= m_size)
            {
                throw IndexErr.make(index).val;
            }
            object old = m_values[i];

            if (i < m_size - 1)
            {
                Array.Copy(m_values, i + 1, m_values, i, m_size - i - 1);
            }
            m_size--;
            return(old);
        }