Oracle Coherence for C++ API
Release 3.6.1.0
E18813-01

- Main Page
- Namespaces
- Classes
- Files

# coherence/util/Arrays.hpp

    00001 /*
    00002 * Arrays.hpp
    00003 *
    00004 * Copyright (c) 2000, 2010, 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         * Copies an array from the specified source array, beginning at the
    00040         * specified position, to the specified position of the destination
    00041         * array.
    00042         *
    00043         * @param haoSrc      the source array
    00044         * @param iSrcStart   starting position in the source array
    00045         * @param haoDest     the destination array
    00046         * @param iDestStart  starting position in the destination data
    00047         * @param cElements   the number of array elements to be copied
    00048         * @throws IndexOutOfBoundsException  if copying would cause
    00049         *               access of data outside array bounds
    00050         */
    00051         static void copy(ObjectArray::Handle haoSrc,
    00052                 size32_t iSrcStart, ObjectArray::Handle haoDest,
    00053                 size32_t iDestStart, size32_t cElements);
    00054
    00055         /**
    00056         * Sorts the specified array of objects according to the order induced
    00057         * by the specified comparator.  All elements in the array must be
    00058         * mutually comparable by the specified comparator.
    00059         *
    00060         * This sort is guaranteed to be stable:  equal elements will not be
    00061         * reordered as a result of the sort.<p>
    00062         *
    00063         * @param hao          the array to be sorted
    00064         * @param hComparator  the comparator to determine the order of the
    00065         *                     array.  A null value indicates that the
    00066         *                     elements' natural ordering should be used
    00067         * @throws ClassCastException  if the array contains elements that are
    00068         *      not mutually comparable
    00069         */
    00070         static void sort(ObjectArray::Handle hao,
    00071                 Comparator::Handle hComparator = NULL);
    00072
    00073         /**
    00074         * Performs a binary search for the specified element in the
    00075         * specified sorted array using the Comparator to compare elements.
    00076         *
    00077         * @param vaoSorted    the sorted Object array to search
    00078         * @param vo           the value element to find
    00079         * @param vComparator  the Comparator (optional)
    00080         *
    00081         * @return the non-negative index of the element, or a negative index
    00082         *         which is the -index - 1 where the element would be inserted
    00083         */
    00084         static int32_t binarySearch(ObjectArray::View vaoSorted,
    00085                 Object::View vo, Comparator::View vComparator = NULL);
    00086
    00087         /**
    00088         * Performs a binary search for the specified element in a part of the
    00089         * specified sorted array using the Comparator to compare elements.
    00090         *
    00091         * @param vaoSorted    the sorted Object array to search
    00092         * @param iStart       the inclusive start index
    00093         * @param iEnd         the exclusive end index
    00094         * @param vo           the value element to find
    00095         * @param vComparator  the Comparator (optional)
    00096         *
    00097         * @return the non-negative index of the element, or a negative index
    00098         *         which is the -index - 1 where the element would be inserted
    00099         */
    00100         static int32_t binarySearch(ObjectArray::View vaoSorted,
    00101                 size32_t iStart, size32_t iEnd, Object::View vo,
    00102                 Comparator::View vComparator = NULL);
    00103     };
    00104
    00105 COH_CLOSE_NAMESPACE2
    00106
    00107 #endif // COH_ARRAYS_HPP

Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.