coherence/util/Arrays.hpp

00001 /*
00002 * Arrays.hpp
00003 *
00004 * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
00005 *
00006 * Oracle is a registered trademarks of Oracle Corporation and/or its
00007 * affiliates.
00008 *
00009 * This software is the confidential and proprietary information of Oracle
00010 * Corporation. You shall not disclose such confidential and proprietary
00011 * information and shall use it only in accordance with the terms of the
00012 * license agreement you entered into with Oracle.
00013 *
00014 * This notice may not be removed or altered.
00015 */
00016 #ifndef COH_ARRAYS_HPP
00017 #define COH_ARRAYS_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/Comparator.hpp"
00022 #include "coherence/util/List.hpp"
00023 
00024 COH_OPEN_NAMESPACE2(coherence,util)
00025 
00026 
00027 /**
00028 * This class contains various methods for manipulating arrays (such as
00029 * sorting and searching).  
00030 *  
00031 * @author tb  2008.04.04
00032 */
00033 class COH_EXPORT Arrays
00034     {
00035     // ----- static methods -------------------------------------------------
00036 
00037     public:
00038         /**
00039         * Sorts the specified array of objects into ascending order, 
00040         * according to the natural ordering of its elements.  All elements in 
00041         * the array must implement the Comparable interface.  Furthermore, 
00042         * all elements in the array must be mutually comparable.
00043         *
00044         * This sort is guaranteed to be stable:  equal elements will not be 
00045         * reordered as a result of the sort.
00046         *
00047         * @param hArray  the array to be sorted
00048         * @throws ClassCastException  if the array contains elements that are 
00049         *      not mutually comparable
00050         */
00051         static void sort(ObjectArray::Handle hArray);
00052        
00053         /**
00054         * Sorts the specified array of objects according to the order induced 
00055         * by the specified comparator.  All elements in the array must be
00056         * mutually comparable by the specified comparator.
00057         *
00058         * This sort is guaranteed to be stable:  equal elements will not be 
00059         * reordered as a result of the sort.<p>
00060         *
00061         * @param hArray       the array to be sorted
00062         * @param hComparator  the comparator to determine the order of the 
00063         *                     array.  A null value indicates that the 
00064         *                     elements' natural ordering should be used
00065         * @throws ClassCastException  if the array contains elements that are 
00066         *      not mutually comparable
00067         */
00068         static void sort(ObjectArray::Handle hArray, 
00069                 Comparator::Handle hComparator);
00070     
00071     };
00072 
00073 COH_CLOSE_NAMESPACE2
00074 
00075 #endif // COH_ARRAYS_HPP
Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.