Skip to content

Commit

Permalink
inputbnd
Browse files Browse the repository at this point in the history
  • Loading branch information
dima424658 committed May 27, 2024
1 parent ac67f2d commit 4aa92d7
Show file tree
Hide file tree
Showing 12 changed files with 1,748 additions and 68 deletions.
1 change: 1 addition & 0 deletions libsrc/cpptools/dlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ template <class CONTAINED_TYPE, int ID>
class cContDListNode : public cDListNode< cContDListNode<CONTAINED_TYPE, ID>, ID>
{
public:
inline cContDListNode() {}
CONTAINED_TYPE item;
};

Expand Down
33 changes: 32 additions & 1 deletion libsrc/inputbnd/aatree.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <cassert>

#ifndef __cplusplus
#error unsupported language
#endif // !__cplusplus
Expand Down Expand Up @@ -34,6 +36,8 @@ struct aatree
int Delete(const char* pName, int iDeleteInfo, T* pInfo);
void DeleteAll(int pDeleteInfo);
T* Find(const char* pName);
void ChangeInfo(const char* pName, T* pInfo, int iInfoArraySize);
void ChangeNodeInfo(const char* pName, T* pInfo, aa_node* pCurrent, int iInfoArraySize);
int GetNumNodes();
void ResetVisited(aa_node* pCurrent);
void VisitBefore(T* pInfo, aa_node* pCurrent);
Expand Down Expand Up @@ -100,6 +104,33 @@ T* aatree<T>::Find(const char* name)
return Search(name, root);
}

template <typename T>
void aatree<T>::ChangeInfo(const char* pName, T* pInfo, int iInfoArraySize)
{
ChangeNodeInfo(pName, pInfo, root, iInfoArraySize);
}

template <typename T>
void aatree<T>::ChangeNodeInfo(const char* pName, T* pInfo, aatree<T>::aa_node* pCurrent, int iInfoArraySize)
{
if (pCurrent == null_node)
return;

if (strcmp(pName, pCurrent->name) == 0)
{
pCurrent->info = pInfo;
pCurrent->info_array_size = iInfoArraySize;
}
else if (strcmp(pName, pCurrent->name) >= 0)
{
ChangeNodeInfo(pName, pInfo, pCurrent->right, iInfoArraySize);
}
else
{
ChangeNodeInfo(pName, pInfo, pCurrent->left, iInfoArraySize);
}
}

template <typename T>
int aatree<T>::GetNumNodes()
{
Expand Down Expand Up @@ -184,7 +215,7 @@ void aatree<T>::Insert(const char* name, T* info, aatree<T>::aa_node** ppOutNode
new_node->info = info;
new_node->info_array_size = info_array_size;
new_node->right = null_node;
new_node->left = new_node->right;
new_node->left = null_node;
new_node->parent = parent;
new_node->level = 1;
new_node->visited = 0;
Expand Down
Loading

0 comments on commit 4aa92d7

Please sign in to comment.