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

F79659-03

coherence/util/Iterator.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_ITERATOR_HPP
00008 #define COH_ITERATOR_HPP
00009 
00010 #include "coherence/lang.ns"
00011 
00012 COH_OPEN_NAMESPACE2(coherence,util)
00013 
00014 
00015 /**
00016 * An object that implements the Iterator interface generates series of
00017 * Object::Holders, one at a time. Successive calls to next() return
00018 * successive elements of the series.
00019 *
00020 * For example, to print all elements of a collection <i>hCol</i>:
00021 * <pre>
00022 * for (Iterator::Handle hIter = hCol->iterator(); hIter->hasNext(); )
00023 *     {
00024 *     std::cout << hIter->next() << std::endl;
00025 *     }
00026 * </pre>
00027 *
00028 * @see Collection
00029 *
00030 * @author jh/mf/nsa  2008.01.28
00031 */
00032 class COH_EXPORT Iterator
00033     : public interface_spec<Iterator>
00034     {
00035     // ----- Iterator interface ---------------------------------------------
00036 
00037     public:
00038         /**
00039         * Determine if the iteration has another element.
00040         *
00041         * @return true if the iterator has another element
00042         */
00043         virtual bool hasNext() const = 0;
00044 
00045         /**
00046         * Return the next element in the iterated series.
00047         *
00048         * @return the next element in the iterated series
00049         *
00050         * @throws coherence::lang::NoSuchElementException if iteration has no
00051         *         more elements
00052         */
00053         virtual Object::Holder next() = 0;
00054     };
00055 
00056 COH_CLOSE_NAMESPACE2
00057 
00058 #endif // COH_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.