summaryrefslogtreecommitdiff
path: root/tables
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2014-07-17 23:58:02 +0000
committerYann Ylavic <ylavic@apache.org>2014-07-17 23:58:02 +0000
commit4a049076c7369bd083fa5c0421e270c6c274a5a4 (patch)
treec425943701d9ccb53fbffbb9c7f3d01749033c98 /tables
parent9fd6562044834f0b641b3c6f957e0175e802281a (diff)
downloadapr-4a049076c7369bd083fa5c0421e270c6c274a5a4.tar.gz
Provide apr_skiplist_size/height/preheight() to get the corresponding values
in O(1), and apr_skiplist_set_preheight() to configure preheight mode. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1611515 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tables')
-rw-r--r--tables/apr_skiplist.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/tables/apr_skiplist.c b/tables/apr_skiplist.c
index a299b7b16..a101ea6fa 100644
--- a/tables/apr_skiplist.c
+++ b/tables/apr_skiplist.c
@@ -25,12 +25,14 @@
#include "apr_skiplist.h"
+#include <limits.h> /* for INT_MAX */
+
struct apr_skiplist {
apr_skiplist_compare compare;
apr_skiplist_compare comparek;
int height;
int preheight;
- int size;
+ size_t size;
apr_skiplistnode *top;
apr_skiplistnode *bottom;
/* These two are needed for appending */
@@ -675,6 +677,26 @@ APR_DECLARE(void *) apr_skiplist_peek(apr_skiplist *a)
return NULL;
}
+APR_DECLARE(size_t) apr_skiplist_size(const apr_skiplist *sl)
+{
+ return sl->size;
+}
+
+APR_DECLARE(int) apr_skiplist_height(const apr_skiplist *sl)
+{
+ return sl->height;
+}
+
+APR_DECLARE(int) apr_skiplist_preheight(const apr_skiplist *sl)
+{
+ return sl->preheight;
+}
+
+APR_DECLARE(void) apr_skiplist_set_preheight(apr_skiplist *sl, int to)
+{
+ sl->preheight = (to > 0) ? to : 0;
+}
+
static void skiplisti_destroy(void *vsl)
{
apr_skiplist_destroy((apr_skiplist *) vsl, NULL);