net.rim.device.api.collection.util
Class ReadableListUtil

java.lang.Object
  |
  +--net.rim.device.api.collection.util.ReadableListUtil

public class ReadableListUtil
extends Object

Utility methods for retrieving data from a readable list. This class assumes that (a) the readable list passed in properly implements ReadableList.size() and ReadableList.getAt(int), and (b) that the invoker of this class's methods does any locking or synchronizing required.


Constructor Summary
ReadableListUtil()
          Constructs a new ReadableListUtil instance.
 
Method Summary
static int getAt(int start, int count, Object[] dest, int destIndex, ReadableList list)
          Retrieves range of elements starting at provided index.
static int getIndex(Object element, ReadableList list)
          Retrieves index by element.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadableListUtil

public ReadableListUtil()
Constructs a new ReadableListUtil instance.

Method Detail

getAt

public static int getAt(int start,
                        int count,
                        Object[] dest,
                        int destIndex,
                        ReadableList list)
Retrieves range of elements starting at provided index.

Parameters:
start - Index of first element to retrieve.
count - Number of elements to retrieve.
dest - Object array to contain returned elements; this array must have enough space to hold the number of elements you expect to receive.
destIndex - Index within destination array to contain the first element retrieved (the destination array must therefore be at least destIndex + count elements long).
list - Readable list from which to fetch the elements.
Returns:
The number of elements actually retrieved.
Throws:
ArrayIndexOutOfBoundsException - If start parameter is not valid.

getIndex

public static int getIndex(Object element,
                           ReadableList list)
Retrieves index by element.

Note: This operation may be linear with respect to the number of elements in the list.

Parameters:
element - Element to locate.
list - Readable list in which to search for the element.
Returns:
Index of provided element, or -1 if the element isn't contained in this collection.



Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.