-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeque_with_array.h
More file actions
59 lines (48 loc) · 1.65 KB
/
deque_with_array.h
File metadata and controls
59 lines (48 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef DATA_STRUCTURES_DEQUE_WITH_ARRAY_H
#define DATA_STRUCTURES_DEQUE_WITH_ARRAY_H
#include "circular_array.h"
namespace DataStructures {
/**
* @class DequeWithArray
* @brief Deque with array class with all relevant functionality.
* @tparam T The type of the implementation class.
*/
template <typename T>
class DequeWithArray {
public:
/**
* @brief Adds an element to the front of the deque.
* @param element The element to be added.
*/
void add_first(const T& element) { arr.add_first(element); }
/**
* @brief Adds an element to the back of the deque.
* @param element The element to be added.
*/
void add_last(const T& element) { arr.add_last(element); }
/**
* @brief Deletes the element at the front of the deque.
* @return The deleted element from the front.
*/
T del_first() { return arr.del_first(); }
/**
* @brief Deletes the element at the back of the deque.
* @return The deleted element from the back.
*/
T del_last() { return arr.del_last(); }
/**
* @brief Gets the value of the element at the front of the deque.
* @return The value of the element at the front of the deque.
*/
T peek_first() const { return arr.get_first(); }
/**
* @brief Gets the value of the element at the back of the deque.
* @return The value of the element at the back of the deque.
*/
T peek_last() const { return arr.get_last(); }
private:
/** The circular array used to internally implement the deque. */
CircularArray<T> arr;
};
} // namespace DataStructures
#endif // DATA_STRUCTURES_DEQUE_WITH_ARRAY_H