From: fred Date: Sat, 30 Nov 1996 10:59:50 +0000 (+0000) Subject: flower-1.0.10 X-Git-Tag: release/1.5.59~6719 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d620ad68cbe1b39f4198aaabd2392535ee0e1756;p=lilypond.git flower-1.0.10 --- diff --git a/flower/list.cc b/flower/list.cc index ce5e366cc8..55e1e20507 100644 --- a/flower/list.cc +++ b/flower/list.cc @@ -36,7 +36,6 @@ List::OK() const template -inline List::~List() { Cursor next(*this); @@ -48,14 +47,17 @@ List::~List() } template -inline void -List::add( const T& thing, Cursor after_me ) +void +List::add( const T& thing, Cursor &after_me ) { if (!size_) { // not much choice if list is empty bottom_ = top_ = new Link( thing ); + if (!after_me.ok()) + after_me = bottom(); } else { // add at aprioprate place - Link *p = ( after_me.ok() ) ? - after_me.pointer() : bottom().pointer(); + if (!after_me.ok()) + after_me = bottom(); + Link *p =after_me.pointer(); p->add(thing); if (p == bottom_) // adjust bottom_ if necessary. bottom_ = p->next(); @@ -75,23 +77,37 @@ List::add( const T& thing, Cursor after_me ) */ template -inline void -List::insert( const T& thing, Cursor before_me ) +void +List::insert( const T& thing, Cursor &before_me ) { if (!size_) { bottom_ = top_ = new Link( thing ); + if (!before_me.ok()) + before_me = top(); + } else { - Link *p = - (before_me.ok())? - before_me.pointer() : top().pointer(); + if (!before_me.ok()) + before_me = top(); + + Link *p = before_me.pointer() ; p->insert(thing); if (p == top_) top_ = p->previous(); } - - size_++; + size_++; } + +template +void +List::concatenate(List const&s) +{ + Cursor b(bottom()); + for (Cursor c(s); c.ok(); c++) { + b.add(c); + b++; + } +} #endif