00001 /* 00002 * ListIterator.hpp 00003 * 00004 * Copyright (c) 2000, 2020, 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_LIST_ITERATOR_HPP 00017 #define COH_LIST_ITERATOR_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/util/Iterator.hpp" 00022 00023 COH_OPEN_NAMESPACE2(coherence,util) 00024 00025 00026 /** 00027 * An iterator for lists that allows the programmer to traverse the list in 00028 * either direction, modify the list during iteration, and obtain the 00029 * iterator's current position in the list. A ListIterator has no current 00030 * element; its cursor position always lies between the element that would be 00031 * returned by a call to previous() and the element that would be returned 00032 * by a call to next(). In a list of length n, there are n+1 valid index 00033 * values, from 0 to n, inclusive. 00034 * 00035 * @author nsa 2008.01.28 00036 */ 00037 class COH_EXPORT ListIterator 00038 : public interface_spec<ListIterator, 00039 implements<Iterator> > 00040 { 00041 // ----- ListIterator interface ----------------------------------------- 00042 00043 public: 00044 /** 00045 * Return the index of the next element to be returned from a call to 00046 * next(). 00047 * 00048 * @return the index of the next element, or the list size if the 00049 * iterator has reached the end of the list 00050 */ 00051 virtual size32_t nextIndex() const = 0; 00052 00053 /** 00054 * Return the index of the element to be returned from a call to 00055 * previous(). 00056 * 00057 * @return the index of the element that would be returned from a call 00058 * to previous, or List::npos if the iterator is at the start 00059 * of the list. 00060 */ 00061 virtual size32_t previousIndex() const = 0; 00062 00063 /** 00064 * Returns true if this list iterator has more elements when 00065 * traversing the list in the reverse direction. 00066 * 00067 * @return true if this list iterator has more elements when 00068 * traversing the list in the reverse direction 00069 */ 00070 virtual bool hasPrevious() const = 0; 00071 00072 /** 00073 * Returns the previous element in the list. 00074 * 00075 * @return the previous element in the list 00076 */ 00077 virtual Object::Holder previous() = 0; 00078 }; 00079 00080 COH_CLOSE_NAMESPACE2 00081 00082 #endif // COH_LIST_ITERATOR_HPP