source: trunk/libtransmission/bitset.h @ 12109

Last change on this file since 12109 was 12109, checked in by jordan, 11 years ago

(trunk libT) finish r12108

  • Property svn:keywords set to Date Rev Author Id
File size: 1.6 KB
Line 
1/*
2 * This file Copyright (C) Mnemosyne LLC
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: bitset.h 12109 2011-03-07 03:46:26Z jordan $
11 */
12
13#ifndef __TRANSMISSION__
14 #error only libtransmission should #include this header.
15#endif
16
17#ifndef TR_BITSET_H
18#define TR_BITSET_H 1
19
20#include "transmission.h"
21#include "bitfield.h"
22
23/** @brief like a tr_bitfield, but supports haveAll and haveNone */
24typedef struct tr_bitset
25{
26    tr_bool haveAll;
27    tr_bool haveNone;
28    tr_bitfield bitfield;
29}
30tr_bitset;
31
32extern const tr_bitset TR_BITSET_INIT;
33
34void tr_bitsetConstruct( tr_bitset * b, size_t bitCount );
35void tr_bitsetDestruct( tr_bitset * b );
36
37void tr_bitsetSetHaveAll( tr_bitset * b );
38void tr_bitsetSetHaveNone( tr_bitset * b );
39
40void tr_bitsetSetBitfield( tr_bitset * b, const tr_bitfield * bitfield );
41
42void tr_bitsetAdd( tr_bitset * b, size_t i );
43void tr_bitsetRem( tr_bitset * b, size_t i );
44void tr_bitsetRemRange ( tr_bitset * b, size_t begin, size_t end );
45
46struct tr_benc;
47tr_bool tr_bitsetFromBenc( tr_bitset * bitset, struct tr_benc * benc );
48void tr_bitsetToBenc( const tr_bitset * bitset, struct tr_benc * benc );
49
50/***
51****
52***/
53
54double tr_bitsetPercent( const tr_bitset * b );
55
56tr_bool tr_bitsetHas( const tr_bitset * b, const size_t nth );
57size_t tr_bitsetCountRange( const tr_bitset * b, const size_t begin, const size_t end );
58
59void tr_bitsetOr( tr_bitfield * a, const tr_bitset * b );
60
61#endif
Note: See TracBrowser for help on using the repository browser.