#include <stream.h>
#include <Index.h>

class TestObject : public Indexable {
public:
  virtual char* classname() { return "TestObject"; }
  virtual IOstatus readContents()  { cin  >> nr_; return Indexable::readContents(); }
  virtual IOstatus writeContents() { cout << nr_; return Indexable::writeContents(); }
  virtual Listable* duplicate() { return new TestObject(*this); }
private:
  int nr_;
};

void testIdefault()
{
  cerr << "Testing Default Iterating through an Index\n";
  Index a(new TestObject);
  int i;  // counter to prevent infinite loops
  Indexable* p;

  a.read();

  for (i = 0, p = a.head();
       p != 0 && i < 100;
       p = p->next(), i++) p->write();

  for (i = 0, p = a.last();
       p != 0 && i < 100;
       p = p->prev(), i++) p->write();
}
