transmission/libtransmission/bitset.h

63 lines
1.7 KiB
C
Raw Normal View History

2009-11-24 03:37:54 +00:00
/*
* This file Copyright (C) Mnemosyne LLC
2009-11-24 03:37:54 +00:00
*
* This file is licensed by the GPL version 2. Works owned by the
2009-11-24 03:37:54 +00:00
* Transmission project are granted a special exemption to clause 2(b)
* so that the bulk of its code can remain under the MIT license.
* This exemption does not extend to derived works not owned by
* the Transmission project.
*
* $Id$
2009-11-24 03:37:54 +00:00
*/
#ifndef __TRANSMISSION__
#error only libtransmission should #include this header.
#endif
#ifndef TR_BITSET_H
#define TR_BITSET_H 1
#include "transmission.h"
#include "bitfield.h"
/** @brief like a tr_bitfield, but supports haveAll and haveNone */
2009-11-24 03:37:54 +00:00
typedef struct tr_bitset
{
tr_bool haveAll;
tr_bool haveNone;
tr_bitfield bitfield;
}
tr_bitset;
extern const tr_bitset TR_BITSET_INIT;
void tr_bitsetConstruct( tr_bitset * b, size_t bitCount );
void tr_bitsetDestruct( tr_bitset * b );
2009-11-24 03:37:54 +00:00
void tr_bitsetSetHaveAll( tr_bitset * b );
void tr_bitsetSetHaveNone( tr_bitset * b );
2009-11-24 03:37:54 +00:00
void tr_bitsetSetBitfield( tr_bitset * b, const tr_bitfield * bitfield );
void tr_bitsetAdd( tr_bitset * b, size_t i );
void tr_bitsetRem( tr_bitset * b, size_t i );
void tr_bitsetRemRange ( tr_bitset * b, size_t begin, size_t end );
struct tr_benc;
tr_bool tr_bitsetFromBenc( tr_bitset * bitset, struct tr_benc * benc );
void tr_bitsetToBenc( const tr_bitset * bitset, struct tr_benc * benc );
2009-11-24 03:37:54 +00:00
/***
****
***/
2009-11-24 03:37:54 +00:00
double tr_bitsetPercent( const tr_bitset * b );
2009-11-24 03:37:54 +00:00
tr_bool tr_bitsetHas( const tr_bitset * b, const size_t nth );
tr_bool tr_bitsetHasSet( const tr_bitset * b, const tr_bitset * compare );
size_t tr_bitsetCountRange( const tr_bitset * b, const size_t begin, const size_t end );
2009-11-24 03:37:54 +00:00
void tr_bitsetOr( tr_bitfield * a, const tr_bitset * b );
2009-11-24 03:37:54 +00:00
#endif