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); } } }
public long binaryFind(Func f) { object[] values = this.m_values; int low = 0, high = m_size - 1; bool oneArg = f.arity() == 1; while (low <= high) { int probe = (low + high) >> 1; object val = values[probe]; object res = oneArg ? f.call(val) : f.call(val, Long.valueOf(probe)); long cmp = ((Long)res).longValue(); if (cmp > 0) { low = probe + 1; } else if (cmp < 0) { high = probe - 1; } else { return(probe); } } return(-(low + 1)); }
public void eachr(Func f) { if (f.arity() == 1) { for (int i = m_size - 1; i >= 0; i--) { f.call(m_values[i]); } } else { for (int i = m_size - 1; i >= 0; i--) { f.call(m_values[i], i); } } }
////////////////////////////////////////////////////////////////////////// // Iterators ////////////////////////////////////////////////////////////////////////// public void each(Func f) { if (f.arity() == 1) { for (int i = 0; i < m_size; i++) { f.call(m_values[i]); } } else { for (int i = 0; i < m_size; i++) { f.call(m_values[i], i); } } }
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); } }
public void eachr(Func f) { if (f.arity() == 1) { for (int i=m_size-1; i>=0; i--) f.call(m_values[i]); } else { for (int i=m_size-1; i>=0; i--) f.call(m_values[i], i); } }
////////////////////////////////////////////////////////////////////////// // Iterators ////////////////////////////////////////////////////////////////////////// public void each(Func f) { if (f.arity() == 1) { for (int i=0; i<m_size; i++) f.call(m_values[i]); } else { for (int i=0; i<m_size; i++) f.call(m_values[i], i); } }
public long binaryFind(Func f) { object[] values = this.m_values; int low = 0, high = m_size-1; bool oneArg = f.arity() == 1; while (low <= high) { int probe = (low + high) >> 1; object val = values[probe]; object res = oneArg ? f.call(val) : f.call(val, Long.valueOf(probe)); long cmp = ((Long)res).longValue(); if (cmp > 0) low = probe + 1; else if (cmp < 0) high = probe - 1; else return probe; } return -(low + 1); }