com.metsci.glimpse.util.primitives
Class BytesArray

java.lang.Object
  extended by com.metsci.glimpse.util.primitives.BytesArray
All Implemented Interfaces:
Bytes, BytesModifiable

public class BytesArray
extends java.lang.Object
implements BytesModifiable

Author:
hogye

Field Summary
 byte[] a
           
static java.nio.charset.CharsetEncoder encoder
           
 int n
           
 
Fields inherited from interface com.metsci.glimpse.util.primitives.Bytes
utf8
 
Constructor Summary
BytesArray()
           
BytesArray(byte[] a)
          For efficiency, does not clone the array arg.
BytesArray(byte[] a, int n)
          For efficiency, does not clone the array arg.
BytesArray(Bytes xs)
          Clones the sequence arg.
BytesArray(int n)
           
BytesArray(java.lang.String s)
           
 
Method Summary
 void append(byte v)
           
 void append(byte[] vs)
           
 void append(byte[] vs, int from, int to)
           
 void append(java.nio.ByteBuffer vs)
           
 void append(java.nio.ByteBuffer vs, int c)
           
 void append(Bytes vs)
           
 void append(Bytes vs, int from, int to)
           
 void append(java.lang.String s)
           
 void append(java.lang.String s, int from, int to)
           
 void compact()
           
 byte[] copyOf()
           
 byte[] copyOf(int i, int c)
           
 void copyTo(int i, byte[] dest, int iDest, int c)
           
 void ensureCapacity(int minCapacity)
           
 byte first()
           
 void insert(int i, byte v)
           
 void insert(int i, byte[] vs)
           
 void insert(int i, byte[] vs, int from, int to)
           
 void insert(int i, java.nio.ByteBuffer vs)
           
 void insert(int i, java.nio.ByteBuffer vs, int c)
           
 void insert(int i, Bytes vs)
           
 void insert(int i, Bytes vs, int from, int to)
           
 void insert(int i, java.lang.String s)
           
 void insert(int i, java.lang.String s, int from, int to)
           
 boolean isEmpty()
           
 byte last()
           
 int n()
          Length of the sequence
static byte[] 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(byte v)
           
 void prepend(byte[] vs)
           
 void prepend(byte[] vs, int from, int to)
           
 void prepend(java.nio.ByteBuffer vs)
           
 void prepend(java.nio.ByteBuffer vs, int c)
           
 void prepend(Bytes vs)
           
 void prepend(Bytes vs, int from, int to)
           
 void prepend(java.lang.String s)
           
 void prepend(java.lang.String s, 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(byte v)
          Removes a single copy of the specified value.
 void set(int i, byte v)
           
 java.lang.String string()
           
 java.lang.String string(int i, int c)
          Strings are encoded and decoded using the UTF-8 charset (multi-byte charsets just aren't worth the increased complication in indexing).
 byte 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

encoder

public static final java.nio.charset.CharsetEncoder encoder

a

public byte[] a

n

public int n
Constructor Detail

BytesArray

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


BytesArray

public BytesArray(int n)

BytesArray

public BytesArray()

BytesArray

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


BytesArray

public BytesArray(Bytes xs)
Clones the sequence arg.


BytesArray

public BytesArray(java.lang.String s)
Method Detail

v

public byte v(int i)
Description copied from interface: Bytes
Value at index i

Specified by:
v in interface Bytes

n

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

Specified by:
n in interface Bytes

copyTo

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

copyOf

public byte[] copyOf(int i,
                     int c)
Specified by:
copyOf in interface Bytes

copyOf

public byte[] copyOf()
Specified by:
copyOf in interface Bytes

string

public java.lang.String string()
Specified by:
string in interface Bytes

string

public java.lang.String string(int i,
                               int c)
Description copied from interface: Bytes
Strings are encoded and decoded using the UTF-8 charset (multi-byte charsets just aren't worth the increased complication in indexing).

Specified by:
string in interface Bytes

isEmpty

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

first

public byte first()
Specified by:
first in interface Bytes

last

public byte last()
Specified by:
last in interface Bytes

set

public void set(int i,
                byte v)
Specified by:
set in interface BytesModifiable

insert

public void insert(int i,
                   byte v)
Specified by:
insert in interface BytesModifiable

insert

public void insert(int i,
                   Bytes vs)
Specified by:
insert in interface BytesModifiable

insert

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

insert

public void insert(int i,
                   java.lang.String s)
Specified by:
insert in interface BytesModifiable

insert

public void insert(int i,
                   java.lang.String s,
                   int from,
                   int to)
Specified by:
insert in interface BytesModifiable

insert

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

insert

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

insert

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

insert

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

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(byte v)
Specified by:
prepend in interface BytesModifiable

prepend

public void prepend(Bytes vs)
Specified by:
prepend in interface BytesModifiable

prepend

public void prepend(Bytes vs,
                    int from,
                    int to)
Specified by:
prepend in interface BytesModifiable

prepend

public void prepend(java.lang.String s)
Specified by:
prepend in interface BytesModifiable

prepend

public void prepend(java.lang.String s,
                    int from,
                    int to)
Specified by:
prepend in interface BytesModifiable

prepend

public void prepend(byte[] vs)
Specified by:
prepend in interface BytesModifiable

prepend

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

prepend

public void prepend(java.nio.ByteBuffer vs)
Specified by:
prepend in interface BytesModifiable

prepend

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

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(byte v)
Specified by:
append in interface BytesModifiable

append

public void append(Bytes vs)
Specified by:
append in interface BytesModifiable

append

public void append(Bytes vs,
                   int from,
                   int to)
Specified by:
append in interface BytesModifiable

append

public void append(java.lang.String s)
Specified by:
append in interface BytesModifiable

append

public void append(java.lang.String s,
                   int from,
                   int to)
Specified by:
append in interface BytesModifiable

append

public void append(byte[] vs)
Specified by:
append in interface BytesModifiable

append

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

append

public void append(java.nio.ByteBuffer vs)
Specified by:
append in interface BytesModifiable

append

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

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(byte v)
Description copied from interface: BytesModifiable
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 BytesModifiable

ensureCapacity

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

compact

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

newArray

public static byte[] 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.