aboutsummaryrefslogtreecommitdiffstats
path: root/Vector.h
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2020-12-07 10:26:01 +0100
committerDaniel Lange <DLange@git.local>2020-12-07 10:26:01 +0100
commit65357c8c46154de4e4eca14075bfe5523bb5fc14 (patch)
tree8f430ee5a0d5de377c4e7c94e47842a27c70d7e8 /Vector.h
parentf80394a20254938142011855f2954b3f63fe5909 (diff)
downloaddebian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.tar.gz
debian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.tar.bz2
debian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.zip
New upstream version 3.0.3upstream/3.0.3
Diffstat (limited to 'Vector.h')
-rw-r--r--Vector.h52
1 files changed, 24 insertions, 28 deletions
diff --git a/Vector.h b/Vector.h
index 209e27c..ee51413 100644
--- a/Vector.h
+++ b/Vector.h
@@ -3,40 +3,38 @@
/*
htop - Vector.h
(C) 2004-2011 Hisham H. Muhammad
-Released under the GNU GPL, see the COPYING file
+Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
#include "Object.h"
-#define swap(a_,x_,y_) do{ void* tmp_ = a_[x_]; a_[x_] = a_[y_]; a_[y_] = tmp_; }while(0)
+#include <stdbool.h>
+
#ifndef DEFAULT_SIZE
-#define DEFAULT_SIZE -1
+#define DEFAULT_SIZE (-1)
#endif
typedef struct Vector_ {
- Object **array;
- ObjectClass* type;
+ Object** array;
+ const ObjectClass* type;
int arraySize;
int growthRate;
int items;
bool owner;
} Vector;
-Vector* Vector_new(ObjectClass* type, bool owner, int size);
+Vector* Vector_new(const ObjectClass* type, bool owner, int size);
void Vector_delete(Vector* this);
-#ifdef DEBUG
-
-int Vector_count(Vector* this);
-
-#endif
-
void Vector_prune(Vector* this);
-void Vector_quickSort(Vector* this);
+void Vector_quickSortCustomCompare(Vector* this, Object_Compare compare);
+static inline void Vector_quickSort(Vector* this) {
+ Vector_quickSortCustomCompare(this, this->type->compare);
+}
void Vector_insertionSort(Vector* this);
@@ -52,29 +50,27 @@ void Vector_moveDown(Vector* this, int idx);
void Vector_set(Vector* this, int idx, void* data_);
-#ifdef DEBUG
+#ifndef NDEBUG
-Object* Vector_get(Vector* this, int idx);
+Object* Vector_get(const Vector* this, int idx);
+int Vector_size(const Vector* this);
+unsigned int Vector_count(const Vector* this);
-#else
+#else /* NDEBUG */
-#define Vector_get(v_, idx_) ((v_)->array[idx_])
+static inline Object* Vector_get(Vector* this, int idx) {
+ return this->array[idx];
+}
-#endif
+static inline int Vector_size(const Vector* this) {
+ return this->items;
+}
-#ifdef DEBUG
-
-int Vector_size(Vector* this);
-
-#else
-
-#define Vector_size(v_) ((v_)->items)
-
-#endif
+#endif /* NDEBUG */
void Vector_add(Vector* this, void* data_);
-int Vector_indexOf(Vector* this, void* search_, Object_Compare compare);
+int Vector_indexOf(const Vector* this, const void* search_, Object_Compare compare);
void Vector_splice(Vector* this, Vector* from);

© 2014-2024 Faster IT GmbH | imprint | privacy policy