source: trunk/libtransmission/bitset.h @ 12003

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

(trunk libT) code cleanup: moving bitset functions to their own .c file.

  • Property svn:keywords set to Date Rev Author Id
File size: 1.3 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 12003 2011-02-21 01:40:19Z 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
32void tr_bitsetReserve( tr_bitset * b, size_t size );
33void tr_bitsetConstructor( tr_bitset * b, size_t size );
34void tr_bitsetDestructor( tr_bitset * b );
35
36void tr_bitsetSetHaveAll( tr_bitset * b );
37void tr_bitsetSetHaveNone( tr_bitset * b );
38
39int  tr_bitsetAdd( tr_bitset * b, size_t i );
40
41/***
42****
43***/
44
45double tr_bitsetPercent( const tr_bitset * b );
46
47tr_bool tr_bitsetHas( const tr_bitset * b, const size_t nth );
48
49void tr_bitsetOr( tr_bitfield * a, const tr_bitset * b );
50
51/* set 'a' to all the flags that were in 'a' but not 'b' */
52void tr_bitsetDifference( tr_bitfield * a, const tr_bitset * b );
53
54#endif
Note: See TracBrowser for help on using the repository browser.