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)); }
public StrBuf replaceRange(Range r, string str) { 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); sb.Insert(s, str); return(this); }
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); }
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)); }
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)); }
////////////////////////////////////////////////////////////////////////// // 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); }
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)); }
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)); }
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); }
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; } }
////////////////////////////////////////////////////////////////////////// // 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); }
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); }
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; } }
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); }
////////////////////////////////////////////////////////////////////////// // 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; } }
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); }
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; } }
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; } }
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); }
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); }
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); }
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; } }
public List getRange(Range r) { try { 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; } List acc = new List(m_of, n); acc.m_size = n; Array.Copy(m_values, s, acc.m_values, 0, n); return(acc); } catch (ArgumentOutOfRangeException) { throw IndexErr.make(r).val; } }
////////////////////////////////////////////////////////////////////////// // Modification ////////////////////////////////////////////////////////////////////////// public List set(long index, object val) { modify(); try { int i = (int)index; if (i < 0) { i = m_size + i; } if (i >= m_size) { throw IndexErr.make(index).val; } m_values[i] = val; return(this); } catch (IndexOutOfRangeException) { throw IndexErr.make(index).val; } }
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); }
public static void make_(IndexErr self) { make_(self, null); }
public static new IndexErr make(string msg, Err cause) { IndexErr err = new IndexErr(); make_(err, msg, cause); return err; }
public static void make_(IndexErr self, string msg) { make_(self, msg, null); }
public static void make_(IndexErr self, string msg, Err cause) { Err.make_(self, msg, cause); }