From b0fe42443b5ebd45e4c91e3062f54d938e14a305 Mon Sep 17 00:00:00 2001 From: nkaaf Date: Sat, 20 Nov 2021 15:42:36 +0100 Subject: [PATCH 1/2] Fix #4; but only for the moment; rewrite is necessary! --- library.properties | 2 +- src/AbstractList.hpp | 7 ++++++- src/SingleLinkedList.hpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/library.properties b/library.properties index 21ebac2..877d48f 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=List -version=1.0.0 +version=1.0.1 author=Niklas Kaaf maintainer=Niklas Kaaf sentence=The Ultimate Collection of Lists diff --git a/src/AbstractList.hpp b/src/AbstractList.hpp index d0fa77c..1b0fef0 100644 --- a/src/AbstractList.hpp +++ b/src/AbstractList.hpp @@ -89,7 +89,9 @@ template class AbstractList { virtual void remove(int index) = 0; /*! - * @brief Get a pointer to the entry at the given index. + * @brief Get a pointer to the entry at the given index. If the given index + * does not exists in the list or the list is immutable, null will be + * returned. * @note If you only want to get the value, use getValue(). * * @param index Index of the element to get. @@ -99,7 +101,10 @@ template class AbstractList { /*! * @brief Get the plain value at the given index. + * @note Be safe, that the given index exists and the list is mutable, + * otherwise the program will crash here! * @see get() + * @todo Rewrite this to let the program not crash! * * @param index Index of element to get. * @return Value. diff --git a/src/SingleLinkedList.hpp b/src/SingleLinkedList.hpp index 3ee5c1b..52c2455 100644 --- a/src/SingleLinkedList.hpp +++ b/src/SingleLinkedList.hpp @@ -209,7 +209,7 @@ template class SingleLinkedList : public AbstractList { } T *get(int index) override { - if (this->isIndexOutOfBounds(index)) { + if (!this->isMutable() || this->isIndexOutOfBounds(index)) { return nullptr; } From 74c747b7677369835d01a5875e0431ed15213132 Mon Sep 17 00:00:00 2001 From: nkaaf Date: Sat, 20 Nov 2021 15:51:37 +0100 Subject: [PATCH 2/2] update version to 1.0.1 --- Doxyfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doxyfile b/Doxyfile index bbf338f..8b93f56 100644 --- a/Doxyfile +++ b/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "Arduino List Library" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.0.0 +PROJECT_NUMBER = 1.0.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a