commit 16e2932c7e0002dd6f7b8ab29dbbb7db00f30d49
parent 1bf0d006195fcb9dc0dcb4f22222d48a0d30dc16
Author: Remy Noulin <loader2x@gmail.com>
Date: Tue, 25 Dec 2018 18:46:02 +0100
add llistCount for element count
linkedList.h | 9 ++++-----
main.c | 2 ++
package.yml | 2 +-
3 files changed, 7 insertions(+), 6 deletions(-)
Diffstat:
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/linkedList.h b/linkedList.h
@@ -30,7 +30,6 @@
* // Free
* llistFree(&ll);
*
- * TODO add node count like singlelist
* TODO create linkedList without head and last
*/
@@ -82,10 +81,10 @@
* */
#define llistNodeType(name) typeof((name)->head)
-// /** TODO
-// * element count in list
-// */
-// #define llistCount(name) (name)->count
+/**
+ * element count in list
+ */
+#define llistCount(name) (dArrayCount(&(name)->list) - dArrayCount(&(name)->freeList))
/**
diff --git a/main.c b/main.c
@@ -34,6 +34,8 @@ int main(int ARGC, char** ARGV) {
llistPush(&ll);
llistLast(&ll) = 1;
+ logVarG(llistCount(&ll));
+
// Pop/dellast element:
llistPop(&ll);
diff --git a/package.yml b/package.yml
@@ -1,6 +1,6 @@
---
name: linkedList
- version: 0.0.1
+ version: 0.0.2
description: "double linked lists"
bin: ./linkedList.h
#cflags: -DA -ggdb -std=gnu11 -fPIC -pipe