|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--xbn.XBNObject | +--xbn.array.UtilArray
Random functions to create, manipulate and analyze arrays.
Source code: UtilArray.java. Unit tests: xbn_junit.array.JUTUtilArray.java.
Fields inherited from class xbn.XBNObject |
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP |
Constructor Summary | |
UtilArray()
Create a UtilArray. |
Method Summary | |
void |
appendTSList(StringOrBuffer str_orBfr,
Object[] a_object,
String s_prefix,
String s_divider,
String s_postfix,
String s_ifNull,
String s_ifEmpty,
String s_ifLmntNull)
Append the list of toStrings for an array of objects onto the provided StringOrBuffer. |
boolean[] |
getAOBClone(boolean[] a_boolean)
Get a full (deep) copy of the provided boolean array. |
char[] |
getAOCClone(char[] a_char)
Get a full (deep) copy of the provided char array. |
int[] |
getAOIClone(int[] a_int)
Get a full (deep) copy of the provided int array. |
Object[] |
getAOOShallowClone(Object[] a_object)
Get a shallow clone of the provided object array. |
AOSLookup |
getAOSLFromAOS(String[] a_string)
Create an AOSLookup from the string array. |
AOSLookup |
getAOSLFromAOS(String[] a_string,
boolean b_listUnqStrs)
Create an AOSLookup from the string array. |
AOSLookup |
getAOSLFromPA(PrimitiveArray primitive_array)
Create an AOSLookup from the PrimitiveArray. |
AOSLookup |
getAOSLFromPA(PrimitiveArray primitive_array,
boolean b_listUnqStrs)
Create an AOSLookup from the PrimitiveArray. |
String[] |
getAOSShallowClone(String[] a_string)
Get a shallow clone of the provided string array. |
int |
getMiddleIdx(int i_idxLeft,
int i_idxRight)
Get the array index in the center of the provided indexes. |
int |
getMiddleIdx(int i_idxLeft,
int i_idxRight,
boolean b_roundLowHigh)
Get the array index in the center of the provided indexes. |
Methods inherited from class xbn.XBNObject |
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public UtilArray()
Create a UtilArray. This constructor does nothing.
Method Detail |
public int getMiddleIdx(int i_idxLeft, int i_idxRight)
Get the array index in the center of the provided indexes.
getMiddleIdx(i_idxLeft, i_idxRight, true)
public int getMiddleIdx(int i_idxLeft, int i_idxRight, boolean b_roundLowHigh)
Get the array index in the center of the provided indexes. This is useful when doing a binary search (see BinarySearchData).
i_idxLeft
- The left-most (starting) index bound.i_idxRight
- The right-most (ending) index bound. This is an inclusive bound (meaning this index is truly the right-most index search, and not the index after it).b_roundLowHigh
- If true, then the returned value will be rounded down (this is the default behavior of int division, and is therefore more efficient). If false, the returned value is rounded up.i_idxRight - i_idxLeft
is less than zero.
i_idxRight - i_idxLeft
is equal to zero.
((i_idxLeft / i_idxRight) + i_idxLeft)
If otherwise. Rounding is taken care of, depending on the value of b_roundLowHigh..public final String[] getAOSShallowClone(String[] a_string)
Get a shallow clone of the provided string array.
Is there any difference between "shallow" and "deep" when it comes to string arrays? My guess is, yes, there is. A deep copy would create new string elements (new String("bla")), where the shallow clone is smart enough to reference the same string objects.
public final Object[] getAOOShallowClone(Object[] a_object)
Get a shallow clone of the provided object array.
public final boolean[] getAOBClone(boolean[] a_boolean)
Get a full (deep) copy of the provided boolean array.
public final char[] getAOCClone(char[] a_char)
Get a full (deep) copy of the provided char array.
public final int[] getAOIClone(int[] a_int)
Get a full (deep) copy of the provided int array.
public final AOSLookup getAOSLFromAOS(String[] a_string)
Create an AOSLookup from the string array.
getAOSLFromAOS(a_string, true)
public final AOSLookup getAOSLFromAOS(String[] a_string, boolean b_listUnqStrs)
Create an AOSLookup from the string array.
getAOSLFromPA((new PASString(a_string)), b_listUnqStrs)
public final AOSLookup getAOSLFromPA(PrimitiveArray primitive_array)
Create an AOSLookup from the PrimitiveArray.
getAOSLFromPA(primitive_array, true)
public final AOSLookup getAOSLFromPA(PrimitiveArray primitive_array, boolean b_listUnqStrs)
Create an AOSLookup from the PrimitiveArray.
primitive_array
- The PrimitiveArray. May not be null, primitive_array.isNull must be false and primitive_array.getLength may not be zero.(false, primitive_array.getLength(), b_listUnqStrs)
. If either of these two conditions are not met, then the AOSLCreator is created with the constructor parameters: (true, b_listUnqStrs)
. The former's internal Hashtable is optimized from the start. The latter recreates (optimizes) the Hashtable after all strings have been added.public final void appendTSList(StringOrBuffer str_orBfr, Object[] a_object, String s_prefix, String s_divider, String s_postfix, String s_ifNull, String s_ifEmpty, String s_ifLmntNull)
Append the list of toStrings for an array of objects onto the provided StringOrBuffer.
str_orBfr
- The StringOrBuffer to append to. May not be null.a_object
- The array of objects to generate toStrings on.s_prefix
- The prefix to append before the toString list, only if a_object is non-null and at least one element in length. If null, then nothing is put before the list (meaning null is the same empty string [''], only faster). If non-null, then this is concatenated to str_orBfr before the toString list.s_divider
- The text to put between each element's toString.s_postfix
- Same as s_prefix, except this is put at the end, after the toString list.s_ifNull
- If a_object is null, then this is the (only) string appended onto str_orBfr. All other string parameters are ignored when a_object is null.s_ifEmpty
- If a_object has zero elements, then this is the (only) string appended onto str_orBfr. All other string parameters are ignored when a_object is zero elements in length.s_ifLmntNull
- When an element within a_object is null, this is the value to appended in place of that element's toString.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.
http://sourceforge.net/projects/xbnjava