com.metsci.glimpse.util.primitives
Class LongsArray

java.lang.Object
  extended by com.metsci.glimpse.util.primitives.LongsArray
All Implemented Interfaces:
Longs, LongsModifiable
Direct Known Subclasses:
SortedLongsArray

public class LongsArray
extends java.lang.Object
implements LongsModifiable

Author:
hogye

Field Summary
 long[] a
           
 int n
           
 
Constructor Summary
LongsArray()
           
LongsArray(int n)
           
LongsArray(long[] a)
          For efficiency, does not clone the array arg.
LongsArray(long[] a, int n)
          For efficiency, does not clone the array arg.
LongsArray(Longs xs)
          Clones the sequence arg.
 
Method Summary
 void append(long v)
           
 void append(long[] vs)
           
 void append(long[] vs, int from, int to)
           
 void append(java.nio.LongBuffer vs)
           
 void append(java.nio.LongBuffer vs, int c)
           
 void append(Longs vs)
           
 void append(Longs vs, int from, int to)
           
 void compact()
           
 long[] copyOf()
           
 long[] copyOf(int i, int c)
           
 void copyTo(int i, long[] dest, int iDest, int c)
           
 void ensureCapacity(int minCapacity)
           
 long first()
           
 void insert(int i, long v)
           
 void insert(int i, long[] vs)
           
 void insert(int i, long[] vs, int from, int to)
           
 void insert(int i, java.nio.LongBuffer vs)
           
 void insert(int i, java.nio.LongBuffer vs, int c)
           
 void insert(int i, Longs vs)
           
 void insert(int i, Longs vs, int from, int to)
           
 boolean isEmpty()
           
 long last()
           
 int n()
          Length of the sequence
static long[] newArray(int oldCapacity, int minNewCapacity)
          Creates a new array whose capacity is at least minNewCapacity, and at least 1.618 * oldCapacity, up to Integer.MAX_VALUE.
 void prepend(long v)
           
 void prepend(long[] vs)
           
 void prepend(long[] vs, int from, int to)
           
 void prepend(java.nio.LongBuffer vs)
           
 void prepend(java.nio.LongBuffer vs, int c)
           
 void prepend(Longs vs)
           
 void prepend(Longs vs, int from, int to)
           
 void prepForAppend(int c)
          Makes room in this array for new values to be appended.
 void prepForInsert(int i, int c)
          Makes room in this array for new values to be inserted.
 void prepForPrepend(int c)
          Makes room in this array for new values to be prepended.
 void remove(long v)
          Removes a single copy of the specified value.
 void set(int i, long v)
           
 long v(int i)
          Value at index i
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

a

public long[] a

n

public int n
Constructor Detail

LongsArray

public LongsArray(long[] a)
For efficiency, does not clone the array arg.


LongsArray

public LongsArray(int n)

LongsArray

public LongsArray()

LongsArray

public LongsArray(long[] a,
                  int n)
For efficiency, does not clone the array arg.


LongsArray

public LongsArray(Longs xs)
Clones the sequence arg.

Method Detail

v

public long v(int i)
Description copied from interface: Longs
Value at index i

Specified by:
v in interface Longs

n

public int n()
Description copied from interface: Longs
Length of the sequence

Specified by:
n in interface Longs

copyTo

public void copyTo(int i,
                   long[] dest,
                   int iDest,
                   int c)
Specified by:
copyTo in interface Longs

copyOf

public long[] copyOf(int i,
                     int c)
Specified by:
copyOf in interface Longs

copyOf

public long[] copyOf()
Specified by:
copyOf in interface Longs

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Longs

first

public long first()
Specified by:
first in interface Longs

last

public long last()
Specified by:
last in interface Longs

set

public void set(int i,
                long v)
Specified by:
set in interface LongsModifiable

insert

public void insert(int i,
                   long v)
Specified by:
insert in interface LongsModifiable

insert

public void insert(int i,
                   Longs vs)
Specified by:
insert in interface LongsModifiable

insert

public void insert(int i,
                   Longs vs,
                   int from,
                   int to)
Specified by:
insert in interface LongsModifiable

insert

public void insert(int i,
                   long[] vs)
Specified by:
insert in interface LongsModifiable

insert

public void insert(int i,
                   long[] vs,
                   int from,
                   int to)
Specified by:
insert in interface LongsModifiable

insert

public void insert(int i,
                   java.nio.LongBuffer vs)
Specified by:
insert in interface LongsModifiable

insert

public void insert(int i,
                   java.nio.LongBuffer vs,
                   int c)
Specified by:
insert in interface LongsModifiable

prepForInsert

public void prepForInsert(int i,
                          int c)
Makes room in this array for new values to be inserted. When this call returns, the values in this.a on [i,i+c) are undefined. Writing meaningful values to these indices is up to the caller.

Parameters:
i - The index at which new values will be inserted
c - The count of new values that will be inserted

prepend

public void prepend(long v)
Specified by:
prepend in interface LongsModifiable

prepend

public void prepend(Longs vs)
Specified by:
prepend in interface LongsModifiable

prepend

public void prepend(Longs vs,
                    int from,
                    int to)
Specified by:
prepend in interface LongsModifiable

prepend

public void prepend(long[] vs)
Specified by:
prepend in interface LongsModifiable

prepend

public void prepend(long[] vs,
                    int from,
                    int to)
Specified by:
prepend in interface LongsModifiable

prepend

public void prepend(java.nio.LongBuffer vs)
Specified by:
prepend in interface LongsModifiable

prepend

public void prepend(java.nio.LongBuffer vs,
                    int c)
Specified by:
prepend in interface LongsModifiable

prepForPrepend

public void prepForPrepend(int c)
Makes room in this array for new values to be prepended. When this call returns, the values in this.a on [0,c) are undefined. Writing meaningful values to these indices is up to the caller.

Parameters:
c - The count of new values that will be inserted

append

public void append(long v)
Specified by:
append in interface LongsModifiable

append

public void append(Longs vs)
Specified by:
append in interface LongsModifiable

append

public void append(Longs vs,
                   int from,
                   int to)
Specified by:
append in interface LongsModifiable

append

public void append(long[] vs)
Specified by:
append in interface LongsModifiable

append

public void append(long[] vs,
                   int from,
                   int to)
Specified by:
append in interface LongsModifiable

append

public void append(java.nio.LongBuffer vs)
Specified by:
append in interface LongsModifiable

append

public void append(java.nio.LongBuffer vs,
                   int c)
Specified by:
append in interface LongsModifiable

prepForAppend

public void prepForAppend(int c)
Makes room in this array for new values to be appended. When this call returns, the values in this.a on [this.n-c,this.n) are undefined. Writing meaningful values to these indices is up to the caller.

Parameters:
c - The count of new values that will be appended

remove

public void remove(long v)
Description copied from interface: LongsModifiable
Removes a single copy of the specified value. If multiple copies are present, there is no guarantee which one will be removed.

Specified by:
remove in interface LongsModifiable

ensureCapacity

public void ensureCapacity(int minCapacity)
Specified by:
ensureCapacity in interface LongsModifiable

compact

public void compact()
Specified by:
compact in interface LongsModifiable

newArray

public static long[] newArray(int oldCapacity,
                              int minNewCapacity)
Creates a new array whose capacity is at least minNewCapacity, and at least 1.618 * oldCapacity, up to Integer.MAX_VALUE.



Copyright © 2012 Metron, Inc.. All Rights Reserved.