]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.76
authorfred <fred>
Fri, 25 Jul 1997 12:47:21 +0000 (12:47 +0000)
committerfred <fred>
Fri, 25 Jul 1997 12:47:21 +0000 (12:47 +0000)
flower/include/acursor.hh [new file with mode: 0644]

diff --git a/flower/include/acursor.hh b/flower/include/acursor.hh
new file mode 100644 (file)
index 0000000..3664b82
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+  acursor.hh -- declare ACursor, PACursor 
+
+  source file of the Flower Library
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef ACURSOR_HH
+#define ACURSOR_HH
+
+template<class T>
+class ACursor
+{
+protected:
+    int idx_;
+    Array<T> &arr_;
+public:
+    ACursor(ACursor const& s) 
+       :arr_(s.arr_)
+    {
+       idx_ = s.idx_;
+    }
+    ACursor(Array<T> const &arr)
+       arr_((Array<T>&)arr)
+    {
+       idx_ =0;
+    }
+    T thing() const { 
+       return arr_[idx_];
+    }
+    T& thing() { return arr_[idx_]; }
+    T& operator++(int) {
+       T&t = thing();
+       idx_ ++;
+       return t;
+    }
+    bool ok() { return idx_ >=0 && idx_ < arr_.size(); }
+};
+
+
+template<class T>
+class PACursor : public ACursor<T*>
+{
+public:
+    PACursor(Link_array<T> l)
+       : ACursor(l)
+    {
+    }
+    T* ptr() { return arr_[idx_]; }
+    T *operator->() {
+       return ptr();
+    }
+    
+};
+
+#endif // ACURSOR_HH