Skip to content

Commit

Permalink
renamed main as test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Gendreau authored and Kyle Gendreau committed Jul 5, 2021
1 parent b28d482 commit 32ced3e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,44 @@
4. [SimpleTrieTemplate Class Template](#simpletrietemplate-class-template)

## Objective
Create a trie that templatizes the key_types, value_types, number of children, and abstracts its mapping/erasing functions.
Create a trie that templatizes the key_types, mapped_types, number of children, and abstracts its mapping/erasing functions.

## Outline

### General
This structure finds inserted values, ie T variables, or value_types, by searching through the trie with respect to a key, ie K variables, or key_types. The methodology of traversing through the trie is orchestrated by the indexer and modifier classes.
The indexer and modifier is part of the template parameters, the indexer returns an index for the next child to visit relative to the current node. The modifier modifies the key and node given the index returned from the indexer.
This structure finds inserted values, ie T variables, or mapped_types, by searching through the trie with respect to a key, ie K variables, or key_types. The methodology of traversing through the trie is orchestrated by the indexer class.
The indexer is part of the template parameters, the indexer returns an index for the next child to visit relative to the current node, while making whatever, if any, modifications along the way.

### Object Details

#### Node Class Template
##### Description:
Node\<typename K, typename T, uint32_t S\> : the node structure used by SimpleTrieTemplate
Node<typename K, typename T, uint32_t S> : the node structure used by SimpleTrieTemplate

##### Member Variables:
variable | description
---------|---------
Node* parent; | a raw pointer to the parent Node of *this
K key; | the key held at *this
std::forward_list\<T\> value; | a list of mapped value types, T
Node* parent_; | a raw pointer to the parent Node of *this
K key_; | the key held at *this
std::optional\<T\> value; | an optional that holds a T value
std::vector\<std::unique_ptr\<Node\>\> child; | a vector of Node type smart pointers that holds S number of children

##### Member Functions:
signature | description
----------|-----------
explicit Node(Node* parentPtr = nullptr, K key = K(), std::forward_list\<T\> value = std::forward_list\<T\>()); | default constructor with defaulted parameters
explicit Node(Node* parent = nullptr); | default constructor with defaulted parameters
explicit Node(K key, Node* parent = nullptr); | alternative constructor that takes a K key type
explicit Node(const Node& rhs); | copy constructor, copies all descendants, but not ancestor nodes
void swap(Node &rhs); | swap function, swaps all values of *this and rhs
Node& operator=(const Node& rhs); | assignment operator, calls swap on a copy constructor with rhs as a parameter
Node& operator=(...parameters...); | takes (const Node&) and (const Node&&) parameters, assignment operator, calls swap on a copy constructor with rhs as a parameter
bool operator==(const Node& rhs); | checks for logical equivalence by comparing all member variables except for parent
bool operator!=(const Node& rhs); | returns the opposite of operator==()



#### Iterator Class Template
##### Description:
Iterator\<typename K, typename T, uin32_t S\> : a forwards iterator used to iterate through the nodes of the trie
Iterator<typename K, typename T, uin32_t S> : a forwards iterator used to iterate through the nodes of the trie.

##### Member Variables:
Nothing public, but describing the private variables might prove useful.
Expand Down
4 changes: 2 additions & 2 deletions main.cpp → test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include <iostream>
#include <map>
#include "./include/SimpleTrieTemplate.h"
#include "./include/DefaultParameters.h"
#include "SimpleTrieTemplate.h"
#include "DefaultParameters.h"

template <typename K, typename T, uint32_t S, typename Indexer, typename Eraser>
void run_standard_tests(SimpleTrieTemplate<K, T, S, Indexer, Eraser> &trie, std::list<std::pair<K,T>>& inserts);
Expand Down

0 comments on commit 32ced3e

Please sign in to comment.