C++ Client API Reference for Oracle Coherence
14c (14.1.2.0.0)

F79659-03

coherence/util/ListIterator.hpp

00001 /*
00002  * Copyright (c) 2000, 2020, Oracle and/or its affiliates.
00003  *
00004  * Licensed under the Universal Permissive License v 1.0 as shown at
00005  * http://oss.oracle.com/licenses/upl.
00006  */
00007 #ifndef COH_LIST_ITERATOR_HPP
00008 #define COH_LIST_ITERATOR_HPP
00009 
00010 #include "coherence/lang.ns"
00011 
00012 #include "coherence/util/Iterator.hpp"
00013 
00014 COH_OPEN_NAMESPACE2(coherence,util)
00015 
00016 
00017 /**
00018 * An iterator for lists that allows the programmer to traverse the list in
00019 * either direction, modify the list during iteration, and obtain the
00020 * iterator's current position in the list. A ListIterator has no current
00021 * element; its cursor position always lies between the element that would be
00022 * returned by a call to previous() and the element that would be returned
00023 * by a call to next(). In a list of length n, there are n+1 valid index
00024 * values, from 0 to n, inclusive.
00025 *
00026 * @author nsa 2008.01.28
00027 */
00028 class COH_EXPORT ListIterator
00029     : public interface_spec<ListIterator,
00030         implements<Iterator> >
00031     {
00032     // ----- ListIterator interface -----------------------------------------
00033 
00034     public:
00035         /**
00036         * Return the index of the next element to be returned from a call to
00037         * next().
00038         *
00039         * @return the index of the next element, or the list size if the
00040         *         iterator has reached the end of the list
00041         */
00042         virtual size32_t nextIndex() const = 0;
00043 
00044         /**
00045         * Return the index of the element to be returned from a call to
00046         * previous().
00047         *
00048         * @return the index of the element that would be returned from a call
00049         *         to previous, or List::npos if the iterator is at the start
00050         *         of the list.
00051         */
00052         virtual size32_t previousIndex() const = 0;
00053 
00054         /**
00055         * Returns true if this list iterator has more elements when
00056         * traversing the list in the reverse direction.
00057         *
00058         * @return true if this list iterator has more elements when
00059         *         traversing the list in the reverse direction
00060         */
00061         virtual bool hasPrevious() const = 0;
00062 
00063         /**
00064         * Returns the previous element in the list.
00065         *
00066         * @return the previous element in the list
00067         */
00068         virtual Object::Holder previous() = 0;
00069     };
00070 
00071 COH_CLOSE_NAMESPACE2
00072 
00073 #endif // COH_LIST_ITERATOR_HPP
Copyright © 2000, 2025, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.