source: trunk/libtransmission/request-list.h @ 7609

Last change on this file since 7609 was 7609, checked in by charles, 12 years ago

(trunk libT) new peer request fifo queue with log(N) search time. new unit tests for the queue. new utility tr_lowerBound()

File size: 1.4 KB
Line 
1/*
2 * This file Copyright (C) 2007-2009 Charles Kerr <charles@transmissionbt.com>
3 *
4 * This file is licensed by the GPL version 2.  Works owned by the
5 * Transmission project are granted a special exemption to clause 2(b)
6 * so that the bulk of its code can remain under the MIT license.
7 * This exemption does not extend to derived works not owned by
8 * the Transmission project.
9 *
10 * $Id:$
11 */
12
13#ifndef __TRANSMISSION__
14#error only libtransmission should #include this header.
15#endif
16
17#ifndef TR_PEER_REQ_H
18#define TR_PEER_REQ_H
19
20#include <inttypes.h>
21
22struct peer_request
23{
24    uint32_t    index;
25    uint32_t    offset;
26    uint32_t    length;
27    time_t      time_requested;
28};
29
30struct request_list
31{
32    size_t                 len;
33    size_t                 max;
34    struct peer_request  * fifo;
35    struct peer_request  * sort;
36};
37
38extern const struct request_list REQUEST_LIST_INIT;
39
40void reqListClear( struct request_list * list );
41
42void reqListCopy( struct request_list * dest, const struct request_list * src );
43
44/* O(log(N)) */
45tr_bool reqListHas( const struct request_list * list, const struct peer_request * key );
46
47/* O(log(N) + 1) */
48void reqListAppend( struct request_list * list, const struct peer_request * req );
49
50/* O(log(N) + 1) */
51tr_bool reqListPop( struct request_list * list, struct peer_request * setme );
52
53/* O(N + log(N)) */
54tr_bool reqListRemove( struct request_list * list, const struct peer_request * key );
55
56
57#endif
Note: See TracBrowser for help on using the repository browser.