站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

ObjectArrayUtilities (Editor Library) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.lib/1 1.14.0 3

org.netbeans.editor
Class ObjectArrayUtilities

java.lang.Object
  extended by org.netbeans.editor.ObjectArrayUtilities

public class ObjectArrayUtilities
extends Object

Utilities over object array.


Method Summary
static int binarySearch(ObjectArray objectArray, Object key)
          Searches the specified object array for the specified object using the binary search algorithm.
static int binarySearch(ObjectArray objectArray, Object key, Comparator c)
          Perform binary search with the specified comparator.
static void copyItems(ObjectArray srcObjectArray, int srcStartIndex, int srcEndIndex, Object[] dest, int destIndex)
          Copy items from the given object array into destination array.
static void copyItems(ObjectArray srcObjectArray, Object[] dest)
          Copy all items from the given object array into destination array.
static int findIndex(ObjectArray objectArray, Object item)
          Get index of the occurrence of the given item in the object array by using binary search and scanning the adjacent items that are equal copmared to the searched item.
static int findIndex(ObjectArray objectArray, Object item, Comparator c)
          Get index of the occurrence of the given item in the object array by using binary search and scanning the adjacent items that are equal copmared to the searched item.
static ObjectArray.Modification mergeModifications(ObjectArray.Modification[] mods)
           
static ObjectArray.Modification mergeModifications(ObjectArray.Modification mod1, ObjectArray.Modification mod2)
           
static void reverse(Object[] array)
          Utility method to reverse order of the elements in the given array.
static Object[] toArray(ObjectArray objectArray)
          Create array and fill it with all the items from the given objectArray.
static Object[] toArray(ObjectArray objectArray, int startIndex, int endIndex)
          Create array and fill it with the items from the given objectArray.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

binarySearch

public static int binarySearch(ObjectArray objectArray,
                               Object key)
Searches the specified object array for the specified object using the binary search algorithm. The object array must be sorted into ascending order according to the natural ordering of its items. If it is not sorted, the results are undefined. If the object array contains multiple elements equal to the specified object, there is no guarantee which one will be found.
This method runs in log(n) time.

Parameters:
objectArray - object array to be searched.
key - the key to be searched for.
Returns:
index of the search key, if it is contained in the object array; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the object array: the index of the first element greater than the key, or objectArray.getItemCount(), if all elements in the object array 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.
Throws:
ClassCastException - if the object array contains elements that are not mutually comparable (for example, strings and integers), or the search key in not mutually comparable with the elements of the object array.
See Also:
Comparable

binarySearch

public static int binarySearch(ObjectArray objectArray,
                               Object key,
                               Comparator c)
Perform binary search with the specified comparator. The more detailed description is given in the doc for binarySearch(ObjectArray, Object).

Parameters:
objectArray - object array to be searched.
key - key to search for.
c - comparator to be used to compare the items.
Returns:
index of the search key, if it is contained in the object array; otherwise, (-(insertion point) - 1).
See Also:
binarySearch(ObjectArray, Object)

findIndex

public static int findIndex(ObjectArray objectArray,
                            Object item)
Get index of the occurrence of the given item in the object array by using binary search and scanning the adjacent items that are equal copmared to the searched item.

Parameters:
objectArray - object array containing the item.
item - object to be found.
Returns:
index of the found object. The object must be the same physical instance as the search item.
For multiple occurrences of the item in the object array a random occurrence is returned.
If the object is not found in the objectArray then this method returns -1.

findIndex

public static int findIndex(ObjectArray objectArray,
                            Object item,
                            Comparator c)
Get index of the occurrence of the given item in the object array by using binary search and scanning the adjacent items that are equal copmared to the searched item.

Parameters:
objectArray - object array containing the item.
item - object to be found.
c - comparator to use to compare the items.
Returns:
index of the found object. The object must be the same physical instance as the search item.
For multiple occurrences of the item in the object array a random occurrence is returned.
If the object is not found in the objectArray then this method returns -1.

toArray

public static Object[] toArray(ObjectArray objectArray)
Create array and fill it with all the items from the given objectArray.

Parameters:
objectArray - objectArray containing items to copy.
Returns:
array containing all the items from the given objectArray.

toArray

public static Object[] toArray(ObjectArray objectArray,
                               int startIndex,
                               int endIndex)
Create array and fill it with the items from the given objectArray.

Parameters:
objectArray - objectArray containing items to copy.
startIndex - index of the first item to copy.
endIndex - index that follows the last item to copy.
Returns:
array containing the requested items from the given objectArray.

copyItems

public static void copyItems(ObjectArray srcObjectArray,
                             Object[] dest)
Copy all items from the given object array into destination array.

Parameters:
srcObjectArray - objectArray containing items to copy.
dest - array into which the items will be copied (at index zero).

copyItems

public static void copyItems(ObjectArray srcObjectArray,
                             int srcStartIndex,
                             int srcEndIndex,
                             Object[] dest,
                             int destIndex)
Copy items from the given object array into destination array.

Parameters:
srcObjectArray - objectArray containing items to copy.
srcStartIndex - index of the first item in the objectArray to copy.
srcEndIndex - index that follows the last item in the objectArray to copy.
dest - array into which the items will be copied.
destIndex - index in the destination array at which the placing of the copied items will be started.

reverse

public static void reverse(Object[] array)
Utility method to reverse order of the elements in the given array.

Parameters:
array - array to be reversed.

mergeModifications

public static ObjectArray.Modification mergeModifications(ObjectArray.Modification mod1,
                                                          ObjectArray.Modification mod2)

mergeModifications

public static ObjectArray.Modification mergeModifications(ObjectArray.Modification[] mods)

org.netbeans.modules.editor.lib/1 1.14.0 3

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.