biddercollection.h


#ifndef BIDDERCOLLECTION_H
#define BIDDERCOLLECTION_H

#include "bidders.h"
#include <iostream>
#include "sllistUtils.h"

//
//  Bidders Registered for auction
//


class BidderCollection {

  int size;
  LListHeader<Bidder> list;

public:

  typedef LListNode<Bidder>* Position;

  /**
   * Create a collection capable of holding any number of items
   */
  BidderCollection ();

  // Big 3
  BidderCollection (const BidderCollection&);
  BidderCollection& operator= (const BidderCollection&);
  ~BidderCollection ();

  

  // Access to attributes
  int getSize() const {return size;}



  // Access to individual elements

  const Bidder& get(Position index) const;
  Bidder& get(Position index);

  Position getFirst() const;
  bool more (Position afterThis) const;
  Position getNext(Position afterThis) const;

  // Collection operations


  void add (const Bidder& value);
  //  Adds this bidder to the collection at an unspecified position.

  //Pre: getSize() < getMaxSize()



  void remove (Position);
  // Remove the item at the indicated position


  Position findBidder (std::string name) const;
  // Returns the position where a bidde mathcing the given
  // name can be found, or null if no bidder with that name exists.



  /**
   * Read all items from the indicated file
   */
  void readBidders (std::string fileName);

  // Print the collection
  void print (std::ostream& out) const;


  // Comparison operators
  bool operator== (const BidderCollection&) const;
  bool operator< (const BidderCollection&) const;


};

inline
std::ostream& operator<< (std::ostream& out, const BidderCollection& b)
{
  b.print(out);
  return out;
}

#endif