public class IntArray extends ArrayBase implements Iterable<Integer>
ArrayBase.TrimARRAY_REGEXC_AMP, C_APOS, C_ATSIGN, C_BACKSLASH, C_BACKSPACE, C_CARET, C_COLON, C_COMMA, C_DEL, C_DOLLAR, C_EQUALS, C_FORMFEED, C_HASH, C_LANGLE, C_LBRAK, C_LCURLY, C_LSQUARE, C_MINUS, C_NBSP, C_NEWLINE, C_NL, C_PERCENT, C_PERIOD, C_PIPE, C_PLUS, C_POUND, C_QUERY, C_QUOT, C_RANGLE, C_RBRAK, C_RCURLY, C_RETURN, C_RSQUARE, C_SEMICOLON, C_SHRIEK, C_SLASH, C_SPACE, C_STAR, C_TAB, C_TILDE, C_UNDER, EPS, F_S, NONWHITEPUNC, NONWHITEPUNC0, NONWHITEPUNC0REGEX, ONE_THIRD, PUNC, S_AMP, S_APOS, S_ATSIGN, S_BACKSLASH, S_CARET, S_COLON, S_COMMA, S_DOLLAR, S_EMPTY, S_EQUALS, S_FORMFEED, S_HASH, S_LANGLE, S_LBRAK, S_LCURLY, S_LSQUARE, S_MINUS, S_NEWLINE, S_NL, S_PERCENT, S_PERIOD, S_PIPE, S_PLUS, S_POUND, S_QUERY, S_QUOT, S_RANGLE, S_RBRAK, S_RCURLY, S_RETURN, S_RSQUARE, S_SEMICOLON, S_SHRIEK, S_SLASH, S_SPACE, S_STAR, S_TAB, S_TILDE, S_UNDER, S_WHITEREGEX, TWO_THIRDS, U_S, WHITESPACE| Constructor and Description |
|---|
IntArray()
create default Array.
|
IntArray(int n)
creates n-element array.
|
IntArray(int[] arr)
create Array from java array.
|
IntArray(IntArray m)
copy constructor.
|
IntArray(IntArray ref,
IntArray sub)
create mixed sliced array.
|
IntArray(IntArray m,
int low,
int high)
create from subarray of another Array.
|
IntArray(int n,
int elem1)
create Array initialized to constant value.
|
IntArray(int n,
int[] arr)
create Array from part of java array.
|
IntArray(int n,
int elem1,
int delta)
create n-element array initialised linearly.
|
IntArray(int nn,
String shape,
int maxval)
Create customized array.
|
IntArray(List<Integer> intList) |
IntArray(String string)
create from a space-separated string of integers.
|
IntArray(String[] strings)
construct from an array of Strings.
|
| Modifier and Type | Method and Description |
|---|---|
int |
absSumAllElements()
sum of all absolute element values.
|
void |
addArray(IntArray f)
append elements.
|
void |
addElement(int f)
append element.
|
IntArray |
applyFilter(IntArray filter)
apply filter.
|
void |
clearArray()
clear all elements of array.
|
Object |
clone()
clone.
|
void |
contractArray()
contracts internal array to be of same length as number of elements.
|
Set<Integer> |
createIntegerSet() |
IntArray |
cumulativeSum()
cumulative sum of array.
|
void |
decrementElementAt(int i) |
void |
deleteElement(int elem)
delete element and close up.
|
void |
deleteElements(int low,
int high)
delete elements and close up.
|
int |
dotProduct(IntArray f)
dot product of two arrays.
|
int |
elementAt(int elem)
get element by index.
|
boolean |
equals(IntArray f)
are two arrays equal.
|
boolean |
equals(Object obj) |
int[] |
getArray()
get java array.
|
Integer |
getConstant()
if all values are equal returns value else null
|
int |
getMax()
value of largest element.
|
int |
getMin()
value of smallest element.
|
IntRange |
getRange()
range of array.
|
IntArray |
getReorderedArray(IntSet idx)
get reordered Array.
|
int[] |
getReverseArray()
get java array in reverse order.
|
String[] |
getStringValues()
returns values as strings.
|
IntArray |
getSubArray(int start,
int end)
get array slice.
|
int |
hashCode() |
void |
incrementElementAt(int i) |
int |
indexOfLargestElement()
index of largest element.
|
int |
indexOfSmallestElement()
index of smallest element.
|
IntSet |
indexSortAscending()
get indexes of ascending sorted array.
|
IntSet |
indexSortDescending()
get indexes of descending sorted array.
|
int |
innerProduct()
inner product.
|
IntSet |
inRange(IntRange r)
get elements within a range.
|
void |
insertArray(int elem,
IntArray f)
insert an array and expand.
|
void |
insertElementAt(int elem,
int f)
insert element and expand.
|
boolean |
isArithmeticProgression(int delta)
returns true if array is of form: i, i+delta, i+2*delta ...
|
boolean |
isClear()
is the array filled with zeros.
|
boolean |
isEqualTo(IntArray f)
are two arrays equal.
|
static boolean |
isIntArray(String s,
String delimiterRegex)
parse string as integerArray.
|
Iterator<Integer> |
iterator() |
int |
largestElement()
value of largest element.
|
IntArray |
multiplyBy(int f)
array multiplication by a scalar.
|
void |
negative()
change the sign of all elements.
|
IntSet |
outOfRange(IntRange r)
get elements outside a range.
|
IntArray |
plus(IntArray f)
adds arrays.
|
void |
reverse()
puts array into reverse order.
|
void |
setAllElements(int f)
initialise array to given value.
|
void |
setElementAt(int elem,
int f)
set element value.
|
void |
setElements(int start,
int[] a)
set array slice.
|
void |
shallowCopy(IntArray m)
shallowCopy
|
int |
size()
get actual number of elements.
|
int |
smallestElement()
value of smallest element.
|
void |
sortAscending()
sorts array into ascending order.
|
void |
sortDescending()
sorts array into descending order.
|
IntArray |
subtract(IntArray f)
subtracts arrays.
|
void |
subtractEquals(IntArray f)
array subtraction.
|
int |
sumAllElements()
sum all elements.
|
String |
toString()
gets values as string.
|
IntArray |
trim(ArrayBase.Trim flag,
int limit)
trims array to lie within limit.
|
finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic IntArray()
public IntArray(int n)
n - size of arraypublic IntArray(int n,
int elem1,
int delta)
n - size of arrayelem1 - starting valuedelta - setpsizepublic IntArray(int n,
int elem1)
n - size of arrayelem1 - value to setpublic IntArray(int n,
int[] arr)
throws EuclidRuntimeException
n - number of elements to usearr - array to read fromEuclidRuntimeException - n larger than arraysizepublic IntArray(int[] arr)
arr - array to read frompublic IntArray(IntArray m, int low, int high) throws EuclidRuntimeException
m - array to slicelow - inclusive start index of arrayhigh - inclusive end index of arrayEuclidRuntimeException - low > high or negative indices or outside size of mpublic IntArray(IntArray ref, IntArray sub) throws EuclidRuntimeException
ref - matrix to slicesub - subscripts.EuclidRuntimeException - if any of I(sub) lies outside 0...refmax-1public IntArray(IntArray m)
m - array to copypublic IntArray(int nn,
String shape,
int maxval)
nn - number of elementsshape - TRIANGLE or ZIGZAGmaxval - used to compute steppublic IntArray(String[] strings) throws NumberFormatException
strings - values as StringsNumberFormatException - a string could not be interpreted as integerpublic IntArray(String string) throws NumberFormatException
string - of form "1 3 56 2..."NumberFormatException - a substring could not be interpreted as integerpublic void contractArray()
public void shallowCopy(IntArray m)
m - public int elementAt(int elem)
throws ArrayIndexOutOfBoundsException
elem - the indexArrayIndexOutOfBoundsException - elem >= size of thispublic int size()
public int[] getArray()
public boolean equals(IntArray f)
f - array to comparepublic void clearArray()
public int[] getReverseArray()
public boolean isEqualTo(IntArray f)
f - array to comparepublic IntArray plus(IntArray f) throws EuclidRuntimeException
f - array to addEuclidRuntimeException - f is different size from thispublic IntArray subtract(IntArray f) throws EuclidRuntimeException
f - array to substractEuclidRuntimeException - f is different size from thispublic void subtractEquals(IntArray f) throws EuclidRuntimeException
f - array to subtractEuclidRuntimeException - f is different size from thispublic void negative()
public IntArray multiplyBy(int f)
f - multiplierpublic void setElementAt(int elem,
int f)
throws ArrayIndexOutOfBoundsException
elem - indexf - valueArrayIndexOutOfBoundsException - elem >= size of thispublic IntArray getSubArray(int start, int end)
start - index inclusiveend - index inclusivepublic void setElements(int start,
int[] a)
start - index in thisa - array to copyArrayIndexOutOfBoundsException - start < 0 or start+a.length > this.size()public boolean isClear()
public void setAllElements(int f)
f - value to setpublic int sumAllElements()
public int absSumAllElements()
public int innerProduct()
public int dotProduct(IntArray f) throws EuclidRuntimeException
f - array to multiplyEuclidRuntimeException - f is different size from thispublic IntArray cumulativeSum()
public IntArray applyFilter(IntArray filter)
filter has <= 1 element, return this
unchanged. filter should have an odd number of elements. The
filter can be created with a IntArray constructor filter is moved along
stepwisefilter - to apply normally smaller than thispublic IntArray trim(ArrayBase.Trim flag, int limit)
flag - BELOW or ABOVElimit - value to constrainpublic int indexOfLargestElement()
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException - array is zero lengthpublic int indexOfSmallestElement()
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException - array is zero lengthpublic int largestElement()
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException - array is zero lengthpublic int getMax()
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException - array is zero lengthpublic int smallestElement()
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException - array is zero lengthpublic int getMin()
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException - array is zero lengthpublic IntRange getRange() throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException - array is zero lengthpublic void deleteElement(int elem)
throws ArrayIndexOutOfBoundsException
elem - to deleteArrayIndexOutOfBoundsException - elem out of rangepublic void deleteElements(int low,
int high)
throws ArrayIndexOutOfBoundsException
low - lowest index inclusivehigh - highest index inclusiveArrayIndexOutOfBoundsException - low or high out of range or low > highpublic void insertElementAt(int elem,
int f)
throws ArrayIndexOutOfBoundsException
elem - index of element to insertf - value of elementArrayIndexOutOfBoundsException - elem out of rangepublic void insertArray(int elem,
IntArray f)
throws ArrayIndexOutOfBoundsException
elem - index of element to insertf - value of elementArrayIndexOutOfBoundsException - elem out of rangepublic void addElement(int f)
f - element to appendpublic void addArray(IntArray f)
f - elements to appendpublic IntArray getReorderedArray(IntSet idx) throws EuclidRuntimeException
idx - array of indexesEuclidRuntimeException - an element of idx is outside range of thispublic IntSet inRange(IntRange r)
r - within which element values must liepublic IntSet outOfRange(IntRange r)
r - outside which element values must liepublic String[] getStringValues()
public String toString()
public void sortAscending()
public void sortDescending()
public void reverse()
public IntSet indexSortAscending()
public IntSet indexSortDescending()
public static boolean isIntArray(String s, String delimiterRegex)
s - delimiterRegex - public boolean isArithmeticProgression(int delta)
delta - public Integer getConstant()
public void decrementElementAt(int i)
public void incrementElementAt(int i)
Copyright © 1994–2024 Peter Murray-Rust. All rights reserved.