// 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. // This is file inludes all the pieces needed for sorted linked lists // Include linked list node class, implemented with free lists #include "linkFL.h" #include "llist.h" // Specialization code to derive a sorted linked list from the generic // linked list definition template class SLList: protected LList > { public: SLList(int size=DefaultListSize) : LList >(size) {} ~SLList() {} // 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; } LList >::insert(it); } LList >::clear; LList >::remove; LList >::moveToStart; LList >::moveToEnd; LList >::prev; LList >::next; LList >::length; LList >::currPos; LList >::moveToPos; LList >::getValue; };