xbn.array
Class VWInt

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.array.VectorWrapper
              |
              +--xbn.array.VWInt
All Implemented Interfaces:
Cloneable

public class VWInt
extends VectorWrapper
implements Cloneable

A VectorWrapper for ints.

Source code:  VWInt.java.  Example code  XmplVWInt.java.


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
VWInt()
          Create a VWInt with default settings.
VWInt(boolean b_orderDirAscDesc)
          Create a VWInt.
VWInt(boolean b_addInOrder, boolean b_orderDirAscDesc)
          Create a VWInt.
VWInt(Vector v_ector)
          Create a VWInt.
VWInt(Vector v_ector, boolean b_orderDirAscDesc)
          Create a VWInt.
VWInt(Vector v_ector, boolean b_addInOrder, boolean b_orderDirAscDesc)
          Create a VWInt.
 
Method Summary
 void add(int i_nt)
          Add an int.
 void addAPInt(APInt ap_int)
          Add an array of ints, as protected by the provided APInt.
 void addArray(int[] a_int)
          Add an array of ints.
protected  Object clone()
          Get a full (deep) copy of this VWInt as an Object.
 boolean doesExist(int i_nt)
          Was an int already added?
 int[] getAOInt()
           
 int[] getAOInt(boolean b_sort)
          Get the array of ints.
 int getFoundIdx(int i_nt)
          Get the index at which the int actually exists.
 int getInsertAddIdx(int i_nt)
          Get the index at which to insert the provided int.
 int getInt(int i_dx)
          Get an int from the vector, at the required array index.
 String getString(int i_dx)
          Get the element at the requested index, as a string.
 VWInt getVWIClone()
          Get a full (deep) copy of this VWInt.
 void increment(int i_ndex, int i_ncrement)
          Add to an existing integer value.
 boolean isNull(int i_dx)
          Is the element at the requested index null?.
 
Methods inherited from class xbn.array.VectorWrapper
doAddInOrder, elementAt, getList, getOrderDirAscDesc, getVector, initializeVector, size
 
Methods inherited from class xbn.XBNObject
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VWInt

public VWInt()

Create a VWInt with default settings.

Equal to VectorWrapper()


VWInt

public VWInt(Vector v_ector)

Create a VWInt.

Equal to VectorWrapper(v_ector)

Note: It is expected that this Vector contain only ints (contained in Integer objects).


VWInt

public VWInt(boolean b_orderDirAscDesc)

Create a VWInt.

Equal to VectorWrapper(b_orderDirAscDesc)


VWInt

public VWInt(Vector v_ector,
             boolean b_orderDirAscDesc)

Create a VWInt.

Equal to VectorWrapper(v_ector, b_orderDirAscDesc)

Note: It is expected that this Vector contain only ints (contained in Integer objects).


VWInt

public VWInt(boolean b_addInOrder,
             boolean b_orderDirAscDesc)

Create a VWInt.

Equal to VectorWrapper(b_addInOrder, b_orderDirAscDesc)


VWInt

public VWInt(Vector v_ector,
             boolean b_addInOrder,
             boolean b_orderDirAscDesc)

Create a VWInt.

Equal to VectorWrapper(v_ector, b_addInOrder, b_orderDisAscDesc)

Note: It is expected that this Vector contain only ints (contained in Integer objects).

Method Detail

add

public final void add(int i_nt)

Add an int.

Parameters:
i_nt - The int to add.

increment

public final void increment(int i_ndex,
                            int i_ncrement)

Add to an existing integer value.


getInsertAddIdx

public final int getInsertAddIdx(int i_nt)

Get the index at which to insert the provided int. This function is only meaningful when adding is ordered. See doAddInOrder.

Parameters:
i_nt - The int you're about to insert. May not be null.
Returns:
If...
  • ...adding is done in order: The array index at which i_nt should be added to preserve the requested ordering. Note that when there are one or more ints equaling i_nt have already been added, then you'll get the array index of (randomly) one of those existing elements.
  • ...size equals zero: 0
  • ...adding is not done in order: 0

getFoundIdx

public final int getFoundIdx(int i_nt)

Get the index at which the int actually exists.

Parameters:
i_nt - The int that may already exist in this VWInt. May not be null.
Returns:
The array index at which i_nt exists. Note that in the case of multiple instances of i_nt, the first (when not adding in order) or random (when adding in order) one is returned.
-1 If no other int equalling i_nt have yet been added.

doesExist

public final boolean doesExist(int i_nt)

Was an int already added?

Parameters:
i_nt - The int who's existence you want to test. May not be null.
Returns:
-1 If no int equalling i_nt exists.
The array index at which the int is found.

addArray

public final void addArray(int[] a_int)

Add an array of ints.

Parameters:
a_int - The int array to add. May not be null.

addAPInt

public final void addAPInt(APInt ap_int)

Add an array of ints, as protected by the provided APInt.

Parameters:
ap_int - The APInt, whose protected array should be add, via addArray. May not be null.

getInt

public final int getInt(int i_dx)

Get an int from the vector, at the required array index.

Parameters:
i_dx - The array index. Must range 0..[size() - 1], inclusive.

getString

public final String getString(int i_dx)
Description copied from class: VectorWrapper

Get the element at the requested index, as a string.

Overrides:
getString in class VectorWrapper
Following copied from class: xbn.array.VectorWrapper
Parameters:
i_dx - The Vector index to retrieve. Must range 0..[size() - 1], inclusive.

isNull

public final boolean isNull(int i_dx)
Description copied from class: VectorWrapper

Is the element at the requested index null?.

Overrides:
isNull in class VectorWrapper
Following copied from class: xbn.array.VectorWrapper
Parameters:
i_dx - The Vector index to analyze. Must range 0..[size() - 1], inclusive.
true - If the requested Vector element is null.
false If non-null.

getAOInt

public final int[] getAOInt()

getAOInt

public final int[] getAOInt(boolean b_sort)

Get the array of ints. This array is composed of all those ints added since this object was created, or since the last time this function was called.

Parameters:
b_sort - If true, then sort the array ascending before returning it (this is redundant when both doAddInOrder and getOrderDirAscDesc equal true). If false, then return the array as it currently exists.
Returns:
An array of ints, as added to this VWInt.

getVWIClone

public final VWInt getVWIClone()

Get a full (deep) copy of this VWInt.

Returns:
(VWInt)clone()

clone

protected final Object clone()
                      throws CloneNotSupportedException

Get a full (deep) copy of this VWInt as an Object.

Overrides:
clone in class Object



Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.

 

http://sourceforge.net/projects/xbnjava

 

SourceForge.net Logo