Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Real-Time Decisions
11g Release 1 (11.1.1)

E17787-01


com.sigmadynamics.sdo.support
Class SDGenericObjectArray

java.lang.Object
  extended by com.sigmadynamics.util.SDArray
      extended by com.sigmadynamics.sdo.support.SDGenericObjectArray


public class SDGenericObjectArray
extends SDArray

Type safe implementation of resizable array containing elements of type GenericObject.

See Also:
Serialized Form

Field Summary
protected  GenericObject[] buf
           
(package private)  boolean needsRehashing
           
(package private)  java.util.HashSet<GenericObject> set
           

 

Fields inherited from class com.sigmadynamics.util.SDArray
ALLOC_UNIT, DEFAULT_INITIAL_SIZE, size

 

Constructor Summary
SDGenericObjectArray()
          Constructs an empty array.
SDGenericObjectArray(int capacity)
          Constructs an empty array with the specified initial capacity.

 

Method Summary
 void add(GenericObject element)
          Appends the specified element to the end of this array.
 void addAll(SDGenericObjectArray array)
          Appends all of the elements in the specified array to the end of this array.
 int capacity()
          Returns buffer capacity.
 boolean contains(GenericObject element)
          Returns true if this array contains the specified element.
 boolean containsAll(SDGenericObjectArray elements)
          Returns true if this array contains all elements of the specified array.
 boolean containsAny(SDGenericObjectArray elements)
          Returns true if this array contains any one of the elements of the specified array.
protected  void ensureCapacity(int capacity)
          Grows the internal buffer as needed to accomodate the specified number of elements.
 boolean equals(java.lang.Object anObject)
          Element by element comparison.
 void fill(GenericObject element)
          Replaces all elements of this array with the same value.
 void fill(int fromIndex, int toIndex, GenericObject element)
          Replaces a group of consequtive elements of this array with the same value.
 GenericObject get(int index)
          Returns the element at the specified position in this array.
static int indexOf(GenericObject element, GenericObject[] array)
          Returns the index in an array of the first occurence of the specified element, or -1 if the array does not contain such element.
 void set(int index, GenericObject element)
          Replaces the element at the specified position in this array with the specified element.
 void setSize(int size)
          Adds or deletes elements at the end of the array.
 void sort()
          Sorts the array in ascending order.
 void sort(java.util.Comparator<GenericObject> c)
          Sorts the array of objects according to the order induced by the specified comparator.
 GenericObject[] toArray()
          Returns an array of GenericObject containing all elements of this one.
 void toArray(GenericObject[] array)
          Copies elements to a given array.
 java.lang.String toString()
          Returns a string representation of this array.
 void trimToSize()
          Removes any excess buffer capacity above the actual number of elements.

 

Methods inherited from class com.sigmadynamics.util.SDArray
clear, isEmpty, rangeCheck, size

 

Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Field Detail

buf

protected GenericObject[] buf

needsRehashing

boolean needsRehashing

set

java.util.HashSet<GenericObject> set

Constructor Detail

SDGenericObjectArray

public SDGenericObjectArray()
Constructs an empty array.

SDGenericObjectArray

public SDGenericObjectArray(int capacity)
Constructs an empty array with the specified initial capacity.
Parameters:
capacity - the initial capacity of the array.

Method Detail

capacity

public int capacity()
Returns buffer capacity.
Specified by:
capacity in class SDArray
Returns:
buffer capacity.

get

public GenericObject get(int index)
Returns the element at the specified position in this array.
Parameters:
index - index of the element to return.
Returns:
The element at the specified position in this array.

set

public void set(int index,
                GenericObject element)
Replaces the element at the specified position in this array with the specified element.
Parameters:
index - index of the element to replace.
element - element to be stored at the specified position.

add

public void add(GenericObject element)
Appends the specified element to the end of this array.
Parameters:
element - element to be appended to this array.

addAll

public void addAll(SDGenericObjectArray array)
Appends all of the elements in the specified array to the end of this array.
Parameters:
array - array containing elements to be appended to this array.

fill

public void fill(GenericObject element)
Replaces all elements of this array with the same value.
Parameters:
element - element that replaces all elements of this array.

fill

public void fill(int fromIndex,
                 int toIndex,
                 GenericObject element)
Replaces a group of consequtive elements of this array with the same value. The group of elements to be replaced consists of elements whose index is between fromIndex, inclusive, and toIndex, exclusive.
Parameters:
fromIndex - index of the first element to be replaced.
toIndex - index after the last element to be replaced.
element - element that replaces the elements from fromIndex to toIndex.

contains

public boolean contains(GenericObject element)
Returns true if this array contains the specified element.
Parameters:
element - element whose presence in this array is to be tested.
Returns:
true if the specified element is present; false otherwise.

containsAll

public boolean containsAll(SDGenericObjectArray elements)
Returns true if this array contains all elements of the specified array.
Parameters:
elements - elements whose presence in this array is to be tested.
Returns:
true if all specified elements is present in this array; false otherwise.

containsAny

public boolean containsAny(SDGenericObjectArray elements)
Returns true if this array contains any one of the elements of the specified array.
Parameters:
elements - elements whose presence in this array is to be tested.
Returns:
true if any specified elements are present in this array; false otherwise.

sort

public void sort()
Sorts the array in ascending order.
Throws:
java.lang.ClassCastException - if the array elements do not implement Comparable interface.
See Also:
Comparable

sort

public void sort(java.util.Comparator<GenericObject> c)
Sorts the array of objects according to the order induced by the specified comparator.
Parameters:
c - the comparator to determine the order of the array. A null value indicates that the natural ordering of the elements should be used.
Throws:
java.lang.ClassCastException - if the array contains elements that are not mutually comparable using the specified comparator.
See Also:
Comparator

equals

public boolean equals(java.lang.Object anObject)
Element by element comparison.
Overrides:
equals in class java.lang.Object
Parameters:
anObject - an object to compare this array with.
Returns:
true if the arrays are equal, false otherwise.

toArray

public GenericObject[] toArray()
Returns an array of GenericObject containing all elements of this one.
Returns:
an array of GenericObject containing all elements of this one.

toArray

public void toArray(GenericObject[] array)
Copies elements to a given array. If the supplied array is shorter than the number of elements in this one, only the elements that fit the supplied array are copied. If the supplied array is longer than the number of elements in this one, the rear part of the supplied array remains unchanged.
Parameters:
array - the array to which the elements of this one are to be copied.
Throws:
java.lang.ArrayStoreException - if the runtime type of the supplied array is not a supertype of the runtime type of every element in this one.

setSize

public void setSize(int size)
Adds or deletes elements at the end of the array.
Specified by:
setSize in class SDArray
Parameters:
size - new number or elements.
Throws:
java.lang.IllegalArgumentException - if size < 0.

trimToSize

public void trimToSize()
Removes any excess buffer capacity above the actual number of elements.
Specified by:
trimToSize in class SDArray

toString

public java.lang.String toString()
Returns a string representation of this array. The string representation consists of elements of the array enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings by String.valueOf(Object).
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this array.

indexOf

public static int indexOf(GenericObject element,
                          GenericObject[] array)
Returns the index in an array of the first occurence of the specified element, or -1 if the array does not contain such element. This method uses linear search.

ensureCapacity

protected void ensureCapacity(int capacity)
Grows the internal buffer as needed to accomodate the specified number of elements.
Specified by:
ensureCapacity in class SDArray
Parameters:
capacity - number of elements to accomodate.

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Real-Time Decisions
11g Release 1 (11.1.1)

E17787-01


Copyright © 2010, Oracle. All rights reserved.