#include #include "ListT.h" using namespace std; ListT::ListT(){ size = 0; current = 0; } bool ListT::IsEmpty(void) const{ return size==0; } bool ListT::IsFull(void) const{ return size==MAX_ITEMS; } size_t ListT::Length(void) const{ return size; } size_t ListT::Find(int key) const { size_t pos=0; bool found = false; while(pos < size and not found) { if (data[pos] == key) { found = true; } else { pos ++; } } return pos; } bool ListT::IsPresent(int key) const{ size_t pos; pos = Find(key); return pos != size; } void ListT::Delete(int key){ bool found; size_t pos = Find(key); found = pos < size; while (found and pos < size-1) { data[pos] = data[pos+1]; pos++; } if (found) { size--; current = 0; } } void ListT::Insert(int key){ if (size < MAX_ITEMS) { data[size] = key; size++; } } void ListT::Reset(void){ current = 0; } bool ListT::HasNext(void) const{ return current < size; } void ListT::Next(void){ if (current < size) { current ++; } } int ListT::GetItem(void) const{ int rv = 0; if (current < size) { rv = data[current]; } return rv; }