]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/include/cursor.icc
release: 1.0.15
[lilypond.git] / flower / include / cursor.icc
index 4fce0b19537a0976bd4e129142a2425c8cffcbd2..ee1f23f2bb044272ae189eda8a21db9e1d070d0b 100644 (file)
@@ -3,7 +3,8 @@
 
   source file of the Flower Library
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 
 
 #include <assert.h>
 
-// untested
+/**
+   Initialisation of Cursor.. Set pointer and list fields.  
+ */
 template<class T>
 inline
-Cursor<T>::Cursor()
- :   list_(*(List<T> *)0)      // ugh
+Cursor<T>::Cursor (const List<T> & list, Link<T>* p )
 {
-  pointer_ = 0;
+  list_l_ =  (List<T> *) &list;        // damn const
+  if (list.size())
+      pointer_ = p ? p : list.top_;
+  else
+      pointer_ = p;
 }
 
 
-template<class T>
-inline
-Cursor<T>::Cursor (const List<T>& list, Link<T>* pointer) : 
-  list_((List<T>&) list)
-{
-  if ( list.size())
-      pointer_ = pointer ? pointer : list.top_;
-  else
-      pointer_ = pointer;
-}
 
 template<class T>
 inline
-Cursor<T>::Cursor (const Cursor<T>& cursor) :
-  list_( cursor.list_)
+Cursor<T>::Cursor (const Cursor<T>& cursor) 
 {
+  list_l_= cursor.list_l_;
   pointer_ = cursor.pointer_;
 }
 
@@ -53,9 +49,9 @@ Cursor<T>::thing()
 
 template<class T>
 Cursor<T>
-Cursor<T>::operator =( const Cursor<T>& c)
+Cursor<T>::operator =(const Cursor<T>& c)
 {   
-  assert (&list_ == &c.list_);
+  assert (list_l_ == c.list_l_);
   pointer_ = c.pointer_;
   return *this;
 }
@@ -64,21 +60,21 @@ template<class T>
 inline void
 Cursor<T>::add (const T& th)
 {
-  list_.add (th, *this);
+  list_l_->add (th, *this);
 }
 
 template<class T>
 inline void
 Cursor<T>::insert (const T& th)
 {
-  list_.insert (th, *this);
+  list_l_->insert (th, *this);
 }
 
 template<class T>
-inline  List<T>&
-Cursor<T>::list() const
+inline List<T> *
+Cursor<T>::list_l() const
 {
-  return list_;
+  return list_l_;              // ugh!
 }
 
 template<class T>
@@ -90,23 +86,23 @@ Cursor<T>::pointer()
 
 template<class T>
 inline bool
-Cursor<T>::backward()const
+Cursor<T>::backward() const
 {
-  return ( pointer_ != 0);
+  return (pointer_ != 0);
 }
 
 template<class T>
 inline bool
-Cursor<T>::forward()const
+Cursor<T>::forward() const
 {
-  return ( pointer_ != 0);
+  return (pointer_ != 0);
 }
 
 template<class T>
 inline bool
-Cursor<T>::ok()const
+Cursor<T>::ok() const
 {
-  return ( pointer_ != 0);
+  return (pointer_ != 0);
 }
 template<class T>
 inline void
@@ -118,7 +114,7 @@ Cursor<T>::next()
 
 template<class T>
 inline Cursor<T> 
-Cursor<T>::operator ++( int)    
+Cursor<T>::operator ++(int)    
 {
   Cursor<T> r (*this);
   next();
@@ -135,7 +131,7 @@ Cursor<T>::previous()
 
 template<class T>
 inline Cursor<T>
-Cursor<T>::operator --( int)
+Cursor<T>::operator --(int)
 {
   Cursor<T> r (*this);
   previous();