Oracle Coherence for C++ API
Release 3.6.0.0

E15728-01

coherence/util/Iterator.hpp

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