java::lang::Array< Type > Class Template Reference

Inheritance diagram for java::lang::Array< Type >:

Inheritance graph
java::lang::Object
[legend]
Collaboration diagram for java::lang::Array< Type >:

Collaboration graph
java::lang::Object
[legend]

List of all members.


Detailed Description

template<class Type>
class java::lang::Array< Type >

Class Array is the template of resizable array.

Author:
Yuh-Jye Chang
Version:
1.0, 06/11/02

Public Member Functions

 Array (jint sz=0)
 Array (jint sz, const Type *src)
 Array (const Array &src)
virtual ~Array ()
Arrayoperator= (const Type &)
Arrayoperator= (const Array &)
Arrayoperator+= (const Type &)
Arrayoperator+= (const Array &)
Array operator+ (const Type &src) const
Array operator+ (const Array &src) const
 operator Type * () const
Type & operator[] (jint index) const
jint length () const
 Returns the length of this array.
void setLength (jint newLength)
 Force the size of the array into the new size.
void trimToLength (jint newLength=-1)
 Trim the capacity of array to the actual usage size.
jint capacity () const
 Returns the capacity of this buffer.
void ensureCapacity (jint minimumCapacity)
 Ensure the capacity of the array match the minimum capacity.
void copy (jint dofs, const Array &sorc, jint sofs=0, jint len=-1)
 Copy the content from source array to this array.
virtual jboolean equals (const Object &a) const
 Returns true if the two specified arrays of bytes are equal to one another.
virtual jboolean equals (const Array &a) const
 Returns true if the two specified arrays of bytes are equal to one another.
virtual jint hashCode () const
 Returns a hash code value for the object.
virtual String toString () const
 Returns a string representation of the object.
void fill (const Type &v, jint fromIndex=0, jint toIndex=-1)
 Assigns the specified value to each element of the specified range of the specified array.
void insert (const Type &v, jint index=-1)
 Insert the specified value to each element of the specified range of the specified array.
void insert (const Array &v, jint index=-1)
 Insert the specified array to each element of the specified range of the specified array.
void remove (jint index, jint toIndex=0)
 Remove the element from the array at the specified index position.
void swap (jint index1, jint index2)
 Swap the elements from the array at the specified index positions.
jint find (const Type &key, jint fromIndex=0, jint toIndex=-1) const
 Find the specified array for the specified object.
jint binarySearch (const Type &key, jint fromIndex=0, jint toIndex=-1) const
 Searches the specified array for the specified object using the binary search algorithm.
void sort (jint fromIndex=0, jint toIndex=-1)
 Sorts the specified range of the specified array into ascending numerical order.
void copyFrom (const Array< ObjectRef > &src)
void copyInto (Array< ObjectRef > &dst) const

Static Public Member Functions

static void arraycopy (Type *dest, const Type *sorc, jint len)
 Copy the content from source buffer to destination buffer.

Protected Member Functions

void init (const Type *, jint _cap)

Protected Attributes

Type * value
jint size
jint cap

Constructor & Destructor Documentation

template<class Type>
java::lang::Array< Type >::Array ( jint  sz = 0  ) 

template<class Type>
java::lang::Array< Type >::Array ( jint  sz,
const Type *  src 
)

template<class Type>
java::lang::Array< Type >::Array ( const Array< Type > &  src  ) 

template<class Type>
virtual java::lang::Array< Type >::~Array (  )  [virtual]


Member Function Documentation

template<class Type>
Array& java::lang::Array< Type >::operator= ( const Type &   ) 

template<class Type>
Array& java::lang::Array< Type >::operator= ( const Array< Type > &   ) 

template<class Type>
Array& java::lang::Array< Type >::operator+= ( const Type &   ) 

template<class Type>
Array& java::lang::Array< Type >::operator+= ( const Array< Type > &   ) 

template<class Type>
Array java::lang::Array< Type >::operator+ ( const Type &  src  )  const [inline]

template<class Type>
Array java::lang::Array< Type >::operator+ ( const Array< Type > &  src  )  const [inline]

template<class Type>
java::lang::Array< Type >::operator Type * (  )  const [inline]

template<class Type>
Type& java::lang::Array< Type >::operator[] ( jint  index  )  const [inline]

template<class Type>
jint java::lang::Array< Type >::length (  )  const [inline]

Returns the length of this array.

The length is equal to the number of elements in the array.

Returns:
the length of the sequence of elements represented by this object.

template<class Type>
void java::lang::Array< Type >::setLength ( jint  newLength  ) 

Force the size of the array into the new size.

Parameters:
numLength the int that identify the new size of the array.

template<class Type>
void java::lang::Array< Type >::trimToLength ( jint  newLength = -1  ) 

Trim the capacity of array to the actual usage size.

template<class Type>
jint java::lang::Array< Type >::capacity (  )  const [inline]

Returns the capacity of this buffer.

The capacity is equal to the number of elements in the array.

Returns:
the capacity of the sequence of elements represented by this object.

template<class Type>
void java::lang::Array< Type >::ensureCapacity ( jint  minimumCapacity  ) 

Ensure the capacity of the array match the minimum capacity.

Parameters:
minimumCapacity the int by which define the minimum capacity.

template<class Type>
static void java::lang::Array< Type >::arraycopy ( Type *  dest,
const Type *  sorc,
jint  len 
) [static]

Copy the content from source buffer to destination buffer.

Parameters:
dest the destination buffer.
sorc the source buffer.
len the copy length

template<class Type>
void java::lang::Array< Type >::copy ( jint  dofs,
const Array< Type > &  sorc,
jint  sofs = 0,
jint  len = -1 
)

Copy the content from source array to this array.

Parameters:
dofs the destination offset.
sorc the source array.
sofs the source offset.
len the copy length. if len == -1 then len = length()-dofs

template<class Type>
virtual jboolean java::lang::Array< Type >::equals ( const Object a  )  const [virtual]

Returns true if the two specified arrays of bytes are equal to one another.

Two arrays are considered equal if both arrays contain the same number of elements, and all corresponding pairs of elements in the two arrays are equal. In other words, two arrays are equal if they contain the same elements in the same order. Also, two array references are considered equal if both are null.

Parameters:
a the other array to be tested for equality.
Returns:
true if the two arrays are equal.

Reimplemented from java::lang::Object.

template<class Type>
virtual jboolean java::lang::Array< Type >::equals ( const Array< Type > &  a  )  const [virtual]

Returns true if the two specified arrays of bytes are equal to one another.

Two arrays are considered equal if both arrays contain the same number of elements, and all corresponding pairs of elements in the two arrays are equal. In other words, two arrays are equal if they contain the same elements in the same order. Also, two array references are considered equal if both are null.

Parameters:
a the other array to be tested for equality.
Returns:
true if the two arrays are equal.

template<class Type>
virtual jint java::lang::Array< Type >::hashCode (  )  const [virtual]

Returns a hash code value for the object.

This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java<font size="-2">TM</font> programming language.)

Returns:
a hash code value for this object.

Reimplemented from java::lang::Object.

template<class Type>
virtual String java::lang::Array< Type >::toString (  )  const [virtual]

Returns a string representation of the object.

In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `</code>', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: <blockquote>

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 
</blockquote>

Returns:
a string representation of the object.

Reimplemented from java::lang::Object.

template<class Type>
void java::lang::Array< Type >::fill ( const Type &  v,
jint  fromIndex = 0,
jint  toIndex = -1 
)

Assigns the specified value to each element of the specified range of the specified array.

The range to be filled extends from index fromIndex, inclusive, to index toIndex, exclusive. (If fromIndex==toIndex, the range to be filled is empty.)

Parameters:
v the value to be stored in all elements of the array.
fromIndex the index of the first element (inclusive) to be filled with the specified value.
toIndex the index of the last element (exclusive) to be filled with the specified value.
Exceptions:
IllegalArgumentException if fromIndex > toIndex
ArrayIndexOutOfBoundsException if fromIndex < 0 or toIndex > a.length

template<class Type>
void java::lang::Array< Type >::insert ( const Type &  v,
jint  index = -1 
)

Insert the specified value to each element of the specified range of the specified array.

The index to be inserted identify by index.

Parameters:
v the value to be inserted in the array.
index the index of the insert position.
Exceptions:
ArrayIndexOutOfBoundsException if index < 0 or index > a.length

template<class Type>
void java::lang::Array< Type >::insert ( const Array< Type > &  v,
jint  index = -1 
)

Insert the specified array to each element of the specified range of the specified array.

The index to be inserted identify by index.

Parameters:
v the array to be inserted in the array.
index the index of the insert position.
Exceptions:
ArrayIndexOutOfBoundsException if index < 0 or index > a.length

template<class Type>
void java::lang::Array< Type >::remove ( jint  index,
jint  toIndex = 0 
)

Remove the element from the array at the specified index position.

Parameters:
index the index of the remove position.
toIndex when 0 means only delete 1 element on the indicated index, when -1 means delete all elements from index to the end for all other value means the end index range.
Exceptions:
ArrayIndexOutOfBoundsException if index < 0 or index > a.length

template<class Type>
void java::lang::Array< Type >::swap ( jint  index1,
jint  index2 
)

Swap the elements from the array at the specified index positions.

Parameters:
index1 the index of the first remove position.
index2 the index of the second remove position.
Exceptions:
ArrayIndexOutOfBoundsException if index < 0 or index > a.length

template<class Type>
jint java::lang::Array< Type >::find ( const Type &  key,
jint  fromIndex = 0,
jint  toIndex = -1 
) const

Find the specified array for the specified object.

The array does not assume a sorted order.

Parameters:
key the value to be found.
fromIndex the index of the first element (inclusive).
toIndex the index of the last element (exclusive).
Returns:
index of the search key, if it is contained in the list; otherwise, (-(insertion point) - 1).

template<class Type>
jint java::lang::Array< Type >::binarySearch ( const Type &  key,
jint  fromIndex = 0,
jint  toIndex = -1 
) const

Searches the specified array for the specified object using the binary search algorithm.

The array must be sorted into ascending order according to the natural ordering of its elements (as by Sort(Object[]), above) prior to making this call. If it is not sorted, the results are undefined. (If the array contains elements that are not mutually comparable (for example,strings and integers), it cannot be sorted according to the natural order of its elements, hence results are undefined.) If the array contains multiple elements equal to the specified object, the last one in the array will be found.

Parameters:
key the value to be searched for.
fromIndex the index of the first element (inclusive).
toIndex the index of the last element (exclusive).
Returns:
index of the search key, if it is contained in the list; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the list: the index of the first element greater than the key, or list.size(), if all elements in the list are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.
Exceptions:
ClassCastException if the search key in not comparable to the elements of the array.
See also:
Comparable

sort(Object[])

template<class Type>
void java::lang::Array< Type >::sort ( jint  fromIndex = 0,
jint  toIndex = -1 
)

Sorts the specified range of the specified array into ascending numerical order.

The range to be sorted extends from index fromIndex, inclusive, to index toIndex, exclusive. (If fromIndex==toIndex, the range to be sorted is empty.)

Parameters:
fromIndex the index of the first element (inclusive) to be sorted.
toIndex the index of the last element (exclusive) to be sorted.
Exceptions:
IllegalArgumentException if fromIndex > toIndex
ArrayIndexOutOfBoundsException if fromIndex < 0 or toIndex > a.length

template<class Type>
void java::lang::Array< Type >::copyFrom ( const Array< ObjectRef > &  src  ) 

template<class Type>
void java::lang::Array< Type >::copyInto ( Array< ObjectRef > &  dst  )  const

template<class Type>
void java::lang::Array< Type >::init ( const Type *  ,
jint  _cap 
) [protected]


Member Data Documentation

template<class Type>
Type* java::lang::Array< Type >::value [protected]

template<class Type>
jint java::lang::Array< Type >::size [protected]

template<class Type>
jint java::lang::Array< Type >::cap [protected]


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:34 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3