// From the software distribution accompanying the textbook // "A Practical Introduction to Data Structures and Algorithm Analysis, // Third Edition (C++)" by Clifford A. Shaffer. // Source code Copyright (C) 2007-2011 by Clifford A. Shaffer. // Sorted array-based list // Inherit from AList as a protected base class template class SAList: protected AList > { public: SAList(int size=defaultSize) : AList >(size) {} ~SAList() {} // Destructor // Redefine insert function to keep values sorted void insert(KVpair& it) { // Insert at right KVpair curr; for (moveToStart(); currPos() < length(); next()) { curr = getValue(); if(curr.key() > it.key()) break; } AList >::insert(it); // Do AList insert } // With the exception of append, all remaining methods are // exposed from AList. Append is not available to SAlist // class users since it has not been explicitly exposed. AList >::clear; AList >::remove; AList >::moveToStart; AList >::moveToEnd; AList >::prev; AList >::next; AList >::length; AList >::currPos; AList >::moveToPos; AList >::getValue; };