Android Programming Press on the image to return to the main documentation page.

CollectionsExtra

Written by Andrew Graham

This library provides an implementation of a doubly linked list that can be used as a stack, queue, or double-ended queue.

It also includes an ArraysExtra object that allows arrays to be partially or full copied, cloned, partially or fully filled with a given value, sorted and searched.
ArraysExtra can also return, using the ToString method, a comma separated string representation of the contents of an array of Strings or a primitive type.

List of types:

ArraysExtra
LinkedList

ArraysExtra

This ArraysExtra object allows arrays to be partially or fully copied, cloned, partially or fully filled with a given value, sorted and searched.
It can also return, using the ToString method, a comma separated string representation of the contents of an array of Strings or a primitive type.

Events:

None

Members:


  ArrayCopy (src As Object, srcOffset As Int, dest As Object, destOffset As Int, count As Int)

  BinarySearch (array As Object, value As Object) As Int

  Clone (array As Object) As Object

  Fill (array As Object, start As Int, len As Int, value As Object)

  SORTCASEINSENSITIVE As Int

  SORTCASESENSITIVE As Int

  SORTNUMERIC As Int

  SortNumericArray (array As Object)

  SortStringArray (array As Object, comparison As Int)

  ToString (array As Object) As String

  Version As Double [read only]

Members description:

ArrayCopy (src As Object, srcOffset As Int, dest As Object, destOffset As Int, count As Int)
Copies all or a section of one array to another existing array of sufficient size to accept the copied items.
The arrays need to be same type otherwise an ArrayStoreException is thrown.
BinarySearch (array As Object, value As Object) As Int
Searches the specified array for the specified value using the binary search algorithm.
The array must be sorted into ascending order according to the natural ordering of its elements, as by the Sort() method, prior to making this call.
If it is not sorted, the results are undefined.
The array must be a single dimension array of Strings or a primitive type.
Clone (array As Object) As Object
Returns a clone, that is a copy, of the specified array.
The array must be a single dimension array of Strings or a primitive type.
Fill (array As Object, start As Int, len As Int, value As Object)
Fully or partially fills the specified array with the specified value.
The array must be a single dimension array of Strings or a primitive type.
SORTCASEINSENSITIVE As Int
SORTCASESENSITIVE As Int
SORTNUMERIC As Int
SortNumericArray (array As Object)
Sorts the specified array of primitive numeric types into ascending numerical order.
SortStringArray (array As Object, comparison As Int)
Sorts the specified array of Strings into ascending order according to the specified comparison.
Note that for use with BinarySearch SORTCASESENSITIVE should be used otherwise the result may not be accurate.
ToString (array As Object) As String
Returns a string representation of the contents of the specified array.
The string representation consists of a list of the array's elements, enclosed in square brackets ("[]").
Adjacent elements are separated by the characters ", " (a comma followed by a space).
Version As Double [read only]
Returns the version of the library.

LinkedList

The LinkedList object provides uniformly named methods to get, remove and insert an element at the beginning and end of the list.
These operations allow linked lists to be used as a stack, queue, or double-ended queue.
All of the operations perform as would be expected for a doubly-linked list.
Operations that index into the list will traverse the list from the beginning or the end, whichever is closer to the specified index.

Events:

None

Members:


  Add (item As Object)

  AddAll (list As List)

  AddAllAt (index As Int, list As List)

  AddFirst (item As Object)

  AddLast (item As Object)

  Clear

  First As Object [read only]

  Get (index As Int) As Object

  IndexOf (item As Object) As Int

  Initialize

  Initialize2 (listorarray As List)

  InsertAt (index As Int, value As Object)

  IsInitialized As Boolean

  Last As Object [read only]

  RemoveAt (index As Int) As Object

  RemoveFirst As Object

  RemoveLast As Object

  Replace (index As Int, item As Object) As Object

  Reverse

  Size As Int [read only]

  Sort (Ascending As Boolean)

  SortCaseInsensitive (Ascending As Boolean)

  Swap (index1 As Int, index2 As Int)

  Version As Double [read only]

Members description:

Add (item As Object)
Appends the specified element to the end of this list.
AddAll (list As List)
Adds all elements in the specified collection to the end of the list.
Note that you can add an array directly.
AddAllAt (index As Int, list As List)
Inserts all the elements in the specified collection into the list starting at the specified index.
Note that you can insert an array directly.
AddFirst (item As Object)
Inserts the specified element at the beginning of this list.
AddLast (item As Object)
Appends the specified element to the end of this list.
Clear
Removes all of the elements from this list.
First As Object [read only]
Retrieves, but does not remove, the first element of this list, or returns null if this list is empty.
Get (index As Int) As Object
Returns the element at the specified position in this list.
IndexOf (item As Object) As Int
Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
Initialize
Initializes an empty linked list.
Initialize2 (listorarray As List)
Initializes a list with the given values. This method should be used to convert arrays to linked lists.
InsertAt (index As Int, value As Object)
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
IsInitialized As Boolean
Last As Object [read only]
Retrieves, but does not remove, the last element of this list, or returns null if this list is empty.
RemoveAt (index As Int) As Object
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.
RemoveFirst As Object
Removes and returns the first element from this list.
RemoveLast As Object
Removes and returns the last element from this list.
Replace (index As Int, item As Object) As Object
Replaces the element at the specified position in this list with the specified element.
Reverse
Reverses the order of the elements in the specified list.
This method runs in linear time.
Size As Int [read only]
Returns the number of elements in this list.
Sort (Ascending As Boolean)
Sorts the list. The items must all be numbers or strings.
SortCaseInsensitive (Ascending As Boolean)
Lexicographically sorts the list, ignoring the characters case. The items must all be numbers or strings.
Swap (index1 As Int, index2 As Int)
Swaps the elements at the specified positions in the specified list.
If the specified positions are equal, invoking this method leaves the list unchanged.
Version As Double [read only]
Returns the version of the library.
Top