|
Boost : |
From: Jan Gaspar (jano_gaspar_at_[hidden])
Date: 2004-04-13 07:18:28
Hi Pavel!
>
> 2. operator[] for circular_buffer itself:
>
> circular_buffer<int> b(10);
> b.push_back(10);
> b.push_back(20);
> b.push_back(33);
> int x = b[-1]; // this would return value 30,
> the last one
> x = b[-2]; // would return 20
>
> This would be new feature, not available in current
> standard ontainers. I remember some language
> (forgot name) provides it.
>
> I personally would like to have this feature
> and have it in std::vector/deque too.
>
I think this can be solved (for any container) by some
kind of adaptor:
template <class Container> ring {
public:
// constructor
ring(const Container& c);
// element access
Container::value_type& operator[] (int index) const;
};
>
> 3. incrementing/decrementing circular_buffer
> iterator with automatic wrap-around:
>
> I think this (wrap-around) should not be
> allowed:
> - it could hide errors
> - it suggests circular-linked-list semantics
> (and one can then ask for rotate())
>
There is a cycle_iterator (yet another
iterator_adaptor application) in the yahoo files
section which can solve this problem.
Jan
__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk