/* ** Copyright (C) 1996, 1997 Microsoft Corporation. All Rights Reserved. ** ** File: utility.hxx ** ** Author: ** ** Description: ** Source for templated methods in the llo library. See llo.h. ** ** History: */ /* ** Definitions for the Slist_utl class: */ template void Slist_utl::purge(bool deleteF) { //Note ... do the test for deleteF outside the loop for speed reasons if (deleteF) { //Nuking an item updates the list's first pointer, //so this works even if it looks funny. Slink_utl* f; while (f = first()) //not == { delete f; } } else { //ditto for unlinking. Slink_utl* f; while (f = first()) //not == { f->unlink(); } } sink(); } template bool Slist_utl::first(const T& t) { Slink_utl* l = new Slink_utl(t); if (l) { first(l); return true; } else return false; } template bool Slist_utl::last(const T& t) { Slink_utl* l = new Slink_utl(t); if (l) { last(l); return true; } else return false; } /* ** Definitions for the Slink_utl class: */ template bool Slink_utl::next(const T& t) { if (m_list) return next(new Slink_utl(t)); else return false; } template bool Slink_utl::txen(const T& t) { if (m_list) return txen(new Slink_utl(t)); else return false; } /* ** Definitions for the Mlist_utl class: */ template void Mlist_utl::purge(bool deleteF) { lock(); //Note ... do the test for deleteF outside the loop for speed reasons if (deleteF) { //Nuking an item updates the list's first pointer, //so this works even if it looks funny. Mlink_utl* f; while (f = first()) //not == { delete f; } } else { //ditto for unlinking. Mlink_utl* f; while (f = first()) //not == { f->unlink(); } } unlock(); } template bool Mlist_utl::first(const T& t) { Mlink_utl* l = new Mlink_utl(t); if (l) { first(l); return true; } else return false; } template bool Mlist_utl::last(const T& t) { Mlink_utl* l = new Mlink_utl(t); if (l) { last(l); return true; } else return false; } template void Mlist_utl::first(Mlink_utl* l) { lock(); List_utl::first(l); unlock(); } template Mlink_utl* Mlist_utl::first(void) const { lock(); Mlink_utl* l = (Mlink_utl*)List_utl::first(); unlock(); return l; } template void Mlist_utl::last(Mlink_utl* l) { lock(); List_utl::last(l); unlock(); } template Mlink_utl* Mlist_utl::last(void) const { lock(); Mlink_utl* l = (Mlink_utl*)List_utl::last(); unlock(); return l; } template Mlink_utl* Mlist_utl::operator [] (int index) const { lock(); Mlink_utl* l = (Mlink_utl*)List_utl::operator [](index); unlock(); return l; } /* ** Definitions for the Mlink_utl class: */ template inline bool Mlink_utl::next(const T& t) { if (m_list) return next(new Mlink_utl(t)); else return false; } template inline bool Mlink_utl::txen(const T& t) { if (m_list) return txen(new Mlink_utl(t)); else return false; }