59 lines
2.4 KiB
C
Raw Normal View History

2015-04-27 22:25:09 +02:00
#ifndef HEADER_CURL_SPLAY_H
#define HEADER_CURL_SPLAY_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
2023-07-02 19:51:09 +02:00
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
2021-09-14 00:13:48 +02:00
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
2022-11-16 20:14:03 +01:00
* SPDX-License-Identifier: curl
*
***************************************************************************/
2015-04-27 22:25:09 +02:00
#include "curl_setup.h"
2018-01-26 17:06:56 +01:00
#include "timeval.h"
struct Curl_tree {
struct Curl_tree *smaller; /* smaller node */
struct Curl_tree *larger; /* larger node */
2017-07-20 19:35:53 +02:00
struct Curl_tree *samen; /* points to the next node with identical key */
struct Curl_tree *samep; /* points to the prev node with identical key */
2018-01-26 17:06:56 +01:00
struct curltime key; /* this node's "sort" key */
void *payload; /* data the splay code doesn't care about */
};
2018-01-26 17:06:56 +01:00
struct Curl_tree *Curl_splay(struct curltime i,
2015-04-27 22:25:09 +02:00
struct Curl_tree *t);
2018-01-26 17:06:56 +01:00
struct Curl_tree *Curl_splayinsert(struct curltime key,
2015-04-27 22:25:09 +02:00
struct Curl_tree *t,
struct Curl_tree *newnode);
2015-04-27 22:25:09 +02:00
2018-01-26 17:06:56 +01:00
struct Curl_tree *Curl_splaygetbest(struct curltime key,
2015-04-27 22:25:09 +02:00
struct Curl_tree *t,
struct Curl_tree **removed);
2015-04-27 22:25:09 +02:00
2021-09-14 00:13:48 +02:00
int Curl_splayremove(struct Curl_tree *t,
struct Curl_tree *removenode,
struct Curl_tree **newroot);
2018-01-26 17:06:56 +01:00
#define Curl_splaycomparekeys(i,j) ( ((i.tv_sec) < (j.tv_sec)) ? -1 : \
( ((i.tv_sec) > (j.tv_sec)) ? 1 : \
2015-04-27 22:25:09 +02:00
( ((i.tv_usec) < (j.tv_usec)) ? -1 : \
2016-09-11 17:22:32 +02:00
( ((i.tv_usec) > (j.tv_usec)) ? 1 : 0))))
2015-04-27 22:25:09 +02:00
#endif /* HEADER_CURL_SPLAY_H */