Skip to content

Commit b0fe424

Browse files
committed
Fix #4; but only for the moment; rewrite is necessary!
1 parent babeb70 commit b0fe424

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=List
2-
version=1.0.0
2+
version=1.0.1
33
author=Niklas Kaaf <[email protected]>
44
maintainer=Niklas Kaaf <[email protected]>
55
sentence=The Ultimate Collection of Lists

src/AbstractList.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ template <typename T> class AbstractList {
8989
virtual void remove(int index) = 0;
9090

9191
/*!
92-
* @brief Get a pointer to the entry at the given index.
92+
* @brief Get a pointer to the entry at the given index. If the given index
93+
* does not exists in the list or the list is immutable, null will be
94+
* returned.
9395
* @note If you only want to get the value, use getValue().
9496
*
9597
* @param index Index of the element to get.
@@ -99,7 +101,10 @@ template <typename T> class AbstractList {
99101

100102
/*!
101103
* @brief Get the plain value at the given index.
104+
* @note Be safe, that the given index exists and the list is mutable,
105+
* otherwise the program will crash here!
102106
* @see get()
107+
* @todo Rewrite this to let the program not crash!
103108
*
104109
* @param index Index of element to get.
105110
* @return Value.

src/SingleLinkedList.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ template <typename T> class SingleLinkedList : public AbstractList<T> {
209209
}
210210

211211
T *get(int index) override {
212-
if (this->isIndexOutOfBounds(index)) {
212+
if (!this->isMutable() || this->isIndexOutOfBounds(index)) {
213213
return nullptr;
214214
}
215215

0 commit comments

Comments
 (0)