Cursor( const Cursor<T>& cursor );
T& thing();
+
/// return current T
T& operator *() { return thing(); }
operator T() { return thing(); }
void concatenate(List<T> const &s);
-
/// make *this empty
void set_empty();
/**
- WARNING: contents lost, and not deleted.
+
+ POST:
+ size == 0
+
+ WARNING:
+ contents lost, and not deleted.
*/
/// add after after_me
/// put thing before #before_me#
void insert( const T& thing, Cursor<T> &before_me );
- virtual void remove( Cursor<T> me );
- /**
- Remove link pointed to by me.
+
+ void remove( Cursor<T> me );
+ /** Remove link pointed to by me. Destructor of contents called
+ (nop for pointers)
POST
- none; WARNING: do not use #me#.
- */
+ none;
+
+
+ WARNING: do not use #me# after calling
+ */
+
+ /****************/
+
int size_;
Link<T>* top_;
Link<T>* bottom_;
template<class T>
struct PCursor : private Cursor<void *> {
friend class IPointerList<T>;
+
+ /// delete contents
+ void junk();
public:
Cursor<void*>::ok;
- Cursor<void*>::del;
- Cursor<void*>::backspace;
+ void del() { junk(); Cursor<void*>::del(); }
+ void backspace() { junk(); Cursor<void*>::backspace(); }
+ T get() {
+ T p = ptr();
+ Cursor<void*>::del();
+ return p;
+ }
+ T get_prev() {
+ (*this)--;
+ return get();
+ }
PointerList<T> &list() { return (PointerList<T>&)Cursor<void*>::list(); }
PCursor<T> operator++(int) { return Cursor<void*>::operator++(0);}
struct IPointerList : public PointerList<T> {
IPointerList(const IPointerList&) { set_empty(); }
IPointerList() { }
-protected:
- virtual void remove( Cursor<void*> me ) { remove (PCursor<T>(me)); }
- virtual void remove( PCursor<T> me );
+ ~IPointerList();
};
/**
NOTE: