![]() ![]() Type Parameters: T - the class of the objects in the list Parameters: list - the list to be searched. O(n) link traversals and O(log n) element comparisons. If the list contains multipleĮlements equal to the specified object, there is no guarantee which one binarySearch public static int binarySearch( List list,Īccording to the specified comparator (as by the.Integers), or the search key is not mutually comparable Mutually comparable (for example, strings and Throws: ClassCastException - if the list contains elements that are not That this guarantees that the return value will be >= 0 ifĪnd only if the key is found. Key would be inserted into the list: the index of the firstĮlement greater than the key, or list.size() if allĮlements in the list are less than the specified key. Insertion point is defined as the point at which the Returns: the index of the search key, if it is contained in the list This method will do an iterator-based binary search that performs If the specified listĭoes not implement the RandomAccess interface and is large, Provides near-constant-time positional access). This method runs in log(n) time for a "random access" list (which If the listĬontains multiple elements equal to the specified object, there is no If it is not sorted, the results are undefined. The list must be sorted into ascending orderĮlements (as by the sort(List) method) prior to making thisĬall. Searches the specified list for the specified object using the binary binarySearch public static int binarySearch( List> list,.IllegalArgumentException - (optional) if the comparator isįound to violate the Comparator contract See Also: List.sort(Comparator) List-iterator does not support the set operation. UnsupportedOperationException - if the specified list's Mutually comparable using the specified comparator. Null value indicates that the elements' natural c - the comparator to determine the order of the list. ![]() Type Parameters: T - the class of the objects in the list Parameters: list - the list to be sorted. Method using the specified list and comparator. All elements in the list must be mutuallyĬomparable using the specified comparator (that is,Ĭ.compare(e1, e2) must not throw a ClassCastException Sorts the specified list according to the order induced by the sort public static void sort( List list,.IllegalArgumentException - (optional) if the implementationĭetects that the natural ordering of the list elements isįound to violate the Comparable contract See Also: List.sort(Comparator) Mutually comparable (for example, strings and integers). Method using the specified list and a null comparator. Implementation Note: This implementation defers to the List.sort(Comparator) The specified list must be modifiable, but need not be resizable. Not be reordered as a result of the sort. This sort is guaranteed to be stable: equal elements will Must not throw a ClassCastException for any elements Mutually comparable (that is, e1.compareTo(e2) Furthermore, all elements in the list must be Sorts the specified list into ascending order, according to theĪll elements in the list must implement the Comparable ForĮxample, invoking the sort method on an unmodifiable list that isĪlready sorted may or may not throw UnsupportedOperationException. These algorithms may, but are not required to, throw thisĮxception if an invocation would have no effect on the collection. Support the appropriate mutation primitive(s), such as the set To throw UnsupportedOperationException if the collection does not The "destructive" algorithms contained in this class, that is, theĪlgorithms that modify the collection on which they operate, are specified (For example, the algorithm used by sort does not have to beĪ mergesort, but it does have to be stable.) Substitute other algorithms, so long as the specification itself is adhered Suchĭescriptions should be regarded as implementation notes, rather than Generally includes a brief description of the implementation. The documentation for the polymorphic algorithms contained in this class If the collections or class objects provided to them are null. The methods of this class all throw a NullPointerException Specified collection, and a few other odds and ends. It contains polymorphic algorithms that operate onĬollections, "wrappers", which return a new collection backed by a This class consists exclusively of static methods that operate on or returnĬollections. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |