284 Peeking Iterator
1 题目
class Iterator {struct Data;Data* data;
public:Iterator(const vector& nums);Iterator(const Iterator& iter);virtual ~Iterator();// Returns the next element in the iteration.int next();// Returns true if the iteration has more elements.bool hasNext() const;
};class PeekingIterator : public Iterator {
public:PeekingIterator(const vector& nums) : Iterator(nums) { }// Returns the next element in the iteration without advancing the iterator.int peek() {return Iterator(*this).next();}};
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
