com.metsci.glimpse.util.primitives
Class CharsArray

java.lang.Object
  extended by com.metsci.glimpse.util.primitives.CharsArray
All Implemented Interfaces:
Chars, CharsModifiable

public class CharsArray
extends java.lang.Object
implements CharsModifiable

Author:
hogye

Field Summary
 char[] a
           
 int n
           
 
Constructor Summary
CharsArray()
           
CharsArray(char[] a)
          For efficiency, does not clone the array arg.
CharsArray(char[] a, int n)
          For efficiency, does not clone the array arg.
CharsArray(Chars xs)
          Clones the sequence arg.
CharsArray(int n)
           
CharsArray(java.lang.String xs)
           
 
Method Summary
 void append(char v)
           
 void append(char[] vs)
           
 void append(char[] vs, int from, int to)
           
 void append(java.nio.CharBuffer vs)
           
 void append(java.nio.CharBuffer vs, int c)
           
 void append(Chars vs)
           
 void append(Chars vs, int from, int to)
           
 void append(java.lang.String vs)
           
 void append(java.lang.String vs, int from, int to)
           
 void compact()
           
 char[] copyOf()
           
 char[] copyOf(int i, int c)
           
 void copyTo(int i, char[] dest, int iDest, int c)
           
 void ensureCapacity(int minCapacity)
           
 char first()
           
 void insert(int i, char v)
           
 void insert(int i, char[] vs)
           
 void insert(int i, char[] vs, int from, int to)
           
 void insert(int i, java.nio.CharBuffer vs)
           
 void insert(int i, java.nio.CharBuffer vs, int c)
           
 void insert(int i, Chars vs)
           
 void insert(int i, Chars vs, int from, int to)
           
 void insert(int i, java.lang.String vs)
           
 void insert(int i, java.lang.String vs, int from, int to)
           
 boolean isEmpty()
           
 char last()
           
 int n()
          Length of the sequence
static char[] 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(char v)
           
 void prepend(char[] vs)
           
 void prepend(char[] vs, int from, int to)
           
 void prepend(java.nio.CharBuffer vs)
           
 void prepend(java.nio.CharBuffer vs, int c)
           
 void prepend(Chars vs)
           
 void prepend(Chars vs, int from, int to)
           
 void prepend(java.lang.String vs)
           
 void prepend(java.lang.String 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(char v)
          Removes a single copy of the specified value.
 void set(int i, char v)
           
 java.lang.String string()
           
 java.lang.String string(int i, int c)
           
 char 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 char[] a

n

public int n
Constructor Detail

CharsArray

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


CharsArray

public CharsArray(int n)

CharsArray

public CharsArray()

CharsArray

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


CharsArray

public CharsArray(Chars xs)
Clones the sequence arg.


CharsArray

public CharsArray(java.lang.String xs)
Method Detail

v

public char v(int i)
Description copied from interface: Chars
Value at index i

Specified by:
v in interface Chars

n

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

Specified by:
n in interface Chars

copyTo

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

copyOf

public char[] copyOf(int i,
                     int c)
Specified by:
copyOf in interface Chars

copyOf

public char[] copyOf()
Specified by:
copyOf in interface Chars

string

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

string

public java.lang.String string(int i,
                               int c)
Specified by:
string in interface Chars

isEmpty

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

first

public char first()
Specified by:
first in interface Chars

last

public char last()
Specified by:
last in interface Chars

set

public void set(int i,
                char v)
Specified by:
set in interface CharsModifiable

insert

public void insert(int i,
                   char v)
Specified by:
insert in interface CharsModifiable

insert

public void insert(int i,
                   Chars vs)
Specified by:
insert in interface CharsModifiable

insert

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

insert

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

insert

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

insert

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

insert

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

insert

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

insert

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

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

prepend

public void prepend(Chars vs)
Specified by:
prepend in interface CharsModifiable

prepend

public void prepend(Chars vs,
                    int from,
                    int to)
Specified by:
prepend in interface CharsModifiable

prepend

public void prepend(java.lang.String vs)
Specified by:
prepend in interface CharsModifiable

prepend

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

prepend

public void prepend(char[] vs)
Specified by:
prepend in interface CharsModifiable

prepend

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

prepend

public void prepend(java.nio.CharBuffer vs)
Specified by:
prepend in interface CharsModifiable

prepend

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

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

append

public void append(Chars vs)
Specified by:
append in interface CharsModifiable

append

public void append(Chars vs,
                   int from,
                   int to)
Specified by:
append in interface CharsModifiable

append

public void append(java.lang.String vs)
Specified by:
append in interface CharsModifiable

append

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

append

public void append(char[] vs)
Specified by:
append in interface CharsModifiable

append

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

append

public void append(java.nio.CharBuffer vs)
Specified by:
append in interface CharsModifiable

append

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

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

ensureCapacity

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

compact

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

newArray

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