mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-23 15:50:49 +01:00
Add class cursor on for all TreeReferences
This commit is contained in:
16
cursor.h
Normal file
16
cursor.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef CURSOR_H
|
||||
#define CURSOR_H
|
||||
|
||||
#include "char_layout_node.h"
|
||||
#include "tree_node.h"
|
||||
#include "tree_reference.h"
|
||||
|
||||
class Cursor {
|
||||
template <typename T>
|
||||
friend class TreeReference;
|
||||
private:
|
||||
Cursor(TreeNode * node) : m_treeReference(node) {}
|
||||
TreeReference<TreeNode> m_treeReference;
|
||||
};
|
||||
|
||||
#endif
|
||||
8
test.cpp
8
test.cpp
@@ -1,7 +1,7 @@
|
||||
#include "float_node.h"
|
||||
#include "char_layout_node.h"
|
||||
#include "addition_node.h"
|
||||
#include "layout_cursor.h"
|
||||
#include "cursor.h"
|
||||
#include <stdio.h>
|
||||
|
||||
Addition buildAddition() {
|
||||
@@ -24,13 +24,13 @@ int main() {
|
||||
printf("\nCHAR LAYOUT\n");
|
||||
CharLayout aChar('a');
|
||||
TreePool::sharedPool()->log();
|
||||
LayoutCursor cursor(aChar.pointer());
|
||||
TreePool::sharedPool()->log();
|
||||
Cursor cursor = aChar.cursor();
|
||||
/* TreePool::sharedPool()->log();
|
||||
cursor.log();
|
||||
bool recompute = false;
|
||||
cursor.moveLeft(&recompute);
|
||||
cursor.log();
|
||||
cursor.moveRight(&recompute);
|
||||
cursor.log();
|
||||
cursor.log();*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,11 @@
|
||||
static inline int min(int i, int j) { return i < j ? i : j; }
|
||||
static inline int max(int i, int j) { return i > j ? i : j; }
|
||||
|
||||
class Cursor;
|
||||
|
||||
template <typename T>
|
||||
class TreeReference {
|
||||
friend class Cursor;
|
||||
public:
|
||||
TreeReference(const TreeReference & tr) {
|
||||
int trNodeIdentifier = tr.identifier();
|
||||
@@ -38,6 +41,8 @@ public:
|
||||
|
||||
int identifier() const { return m_identifier; }
|
||||
|
||||
Cursor cursor();
|
||||
|
||||
// Hierarchy
|
||||
int numberOfChildren() const {
|
||||
return node()->numberOfChildren();
|
||||
|
||||
Reference in New Issue
Block a user