#1 Added operator overload, [], to Linked List
This commit is contained in:
@ -9,7 +9,7 @@ namespace Datastructures {
|
||||
LinkedList();
|
||||
LinkedList(T value);
|
||||
~LinkedList();
|
||||
T operator[](int index);
|
||||
T& operator[](int index);
|
||||
void append(T value);
|
||||
bool insert(T value, int index);
|
||||
bool remove(int index);
|
||||
@ -43,6 +43,12 @@ namespace Datastructures {
|
||||
template <typename T>
|
||||
LinkedList<T>::~LinkedList() {}
|
||||
|
||||
template <typename T>
|
||||
T& LinkedList<T>::operator[](int index) {
|
||||
//Return the value from a given index. (Will return null pointer if out of range)
|
||||
return this->getIndex(index)->value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void LinkedList<T>::append(T value) {
|
||||
mCount++;
|
||||
|
Reference in New Issue
Block a user