set_iterator


template <class t>
struct set_iterator
{
   node* _node; 

  set_iterator() : _node(0) {}

  set_iterator(node* in) : _node(in) {}

  t& operator*() const
  {
   return ((set_node<t,less>*)_node)->element;
  }

  t* operator->() const
  {
   return &((set_node<t,less>*)_node)->element;
  }

  t* operator&() const
  {
   return &((set_node<t,less>*)_node)->element;
  }

  set_iterator& operator++()
  {_node = next_item(_node); return *this;}

  set_iterator operator++(int)
  {set_iterator save = *this; ++*this ;return save;}

  set_iterator& operator+=(long long increment)
  {for (long long i=0; i<increment; i++) ++*this; return *this;}

  set_iterator operator+(long long increment) const
  {
   set_iterator result(*this);
   for (long long i=0; i<increment; i++) ++result;
   return result;
  }

  set_iterator& operator--()
  {_node = previous_item(_node); return *this;}

  set_iterator operator--(int)
  {set_iterator save = *this; --*this ;return save;}

  set_iterator& operator-=(long long decrement)
  {for (long long i=0; i<decrement; i++) --*this; return *this;}

  set_iterator operator-(long long decrement) const
  {
   set_iterator result(*this);
   for (long long i=0; i<decrement; i++) --result;
   return result;
  }

  bool operator==(const set_iterator& y) const {return _node == y._node;}

  bool operator!=(const set_iterator& y) const {return _node != y._node;}

  const t& operator[](Integer i) const {return i>=0 ? *(*this + i) : *(*this - -i);}  

  long long operator-(set_iterator iter) const
  {
   long long result=0;
   while (iter++ != *this) {result++;}
   return result;
  }

  bool is_header() const {return _node->is_header();}
};