@@ -38,9 +38,6 @@ template <class T, class D> class Component {
3838 std::string toString ();
3939
4040 // State
41- bool isempty ();
42- bool isempty (int lvl);
43- bool isExplicitEmpty ();
4441 bool single (int lvl);
4542
4643 Levels<T, D> mPartial ;
@@ -93,57 +90,35 @@ template <class T, class D> std::string Component<T, D>::toString() {
9390/* ==============================================================================
9491 Stack Functions: push, pop, top, topIndex, isempty, isExplicitEmpty
9592==============================================================================*/
96- template <class T , class D > bool Component<T, D>::isempty() {
97- bool b = true ;
98- for (int lvl = 0 ; lvl <= int (mPartial .size ()); lvl++) {
99- b = b && isempty (lvl);
100- }
101- return b;
102- }
103-
104- template <class T , class D > bool Component<T, D>::isempty(int lvl) {
105- bool b;
106- if (lvl >= int (mPartial .size ())) {
107- b = isExplicitEmpty ();
108- } else {
109- b = (mPartial [lvl]).empty ();
110- }
111- return b;
112- }
113-
114- template <class T , class D > bool Component<T, D>::isExplicitEmpty() {
115- return (mExplicit .empty ());
116- }
117-
11893template <class T , class D >
11994void Component<T, D>::pushExplicit(SPData<T, D> elt) {
12095 mExplicit .push_back (elt);
12196}
12297template <class T , class D >
12398void Component<T, D>::push(Signature<T, D> sign, int lvl) {
124- mPartial [lvl].push_back (sign);
99+ mPartial [lvl - 1 ].push_back (sign);
125100}
126101
127102template <class T , class D > Data<T, D> Component<T, D>::top() {
128103 return *(mExplicit .back ());
129104}
130105template <class T , class D > Signature<T, D> Component<T, D>::top(int lvl) {
131- return mPartial [lvl].back ();
106+ return mPartial [lvl - 1 ].back ();
132107}
133108
134109template <class T , class D > int Component<T, D>::topIndex(int lvl) {
135- if (lvl == 0 ) {
136- return top ().mIndex ;
137- } else {
110+ if (lvl > 0 && lvl <= (int )mPartial .size ()) {
138111 return top (lvl).mLast ;
112+ } else {
113+ return top ().mIndex ;
139114 }
140115}
141116
142117template <class T , class D > bool Component<T, D>::single(int lvl) {
143- if (mPartial [lvl].empty ()) {
118+ if (mPartial [lvl - 1 ].empty ()) {
144119 return false ;
145120 }
146- return (mPartial [lvl].back ().single ());
121+ return (mPartial [lvl - 1 ].back ().single ());
147122}
148123
149124/* ==============================================================================
0 commit comments