Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
refactor and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
specialfish9 committed Sep 3, 2021
1 parent cfa4964 commit 99b0d58
Show file tree
Hide file tree
Showing 3 changed files with 259 additions and 92 deletions.
74 changes: 47 additions & 27 deletions src/nostd/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,60 @@
namespace Nostd {

/*
* Map
*
* Pure virtual class extended by Nostd::UnorderedMap and Nostd::TreeMap
*
* */
Map: pure virtual class extended by Nostd::UnorderedMap and Nostd::TreeMap
*/

template <typename K, typename V> class Map {
public:
/// Insert a new pair Key Value
/*
Insert a new pair Key Value
*/
virtual void put(K key, V value) = 0;

/// Remove a key and its value
/*
Remove a key and its value
*/
virtual void remove(K key) = 0;

/// Check wheter the map has no keys
virtual bool empty() const = 0;

/// Check wheter the map contains the key
virtual bool contains(K key) const = 0;

/// Remove all elements
virtual void clear() = 0;

/// Returns all the values inside the map as Nostd::Vector<V>
virtual Nostd::Vector<V> get_values() const = 0;

/// Returns all the Key-Values pairs as Nostd::Vector<Nostd::Pair<K,V>>
virtual Nostd::Vector<Nostd::Pair<const K, V> *> as_vector() const = 0;

virtual size_t size() const = 0;

virtual V &operator[](K key) = 0;

virtual const V &operator[](K key) const = 0;
/*
Check wheter the map has no keys
*/
virtual bool empty(void) const = 0;

/*
Check wheter the map contains the key
*/
virtual bool contains(const K &key) const = 0;

/*
Remove all elements
*/
virtual void clear(void) = 0;

/*
Returns all the values inside the map as Nostd::Vector<V>
*/
virtual Nostd::Vector<V> get_values(void) const = 0;

/*
Returns all the Key-Values pairs as Nostd::Vector<Nostd::Pair<K,V>>
*/
virtual Nostd::Vector<Nostd::Pair<const K, V> *> as_vector(void) const = 0;

/*
Returns the number of elements inside the map
*/
virtual size_t size(void) const = 0;

/*
Access a value from its key
*/
virtual V &operator[](const K &key) = 0;

/*
Access a value from its key
*/
virtual const V &operator[](const K &key) const = 0;
};

} // namespace Nostd
Expand Down
Loading

0 comments on commit 99b0d58

Please sign in to comment.