2009-11-24 03:37:54 +00:00
|
|
|
/*
|
2011-01-19 13:48:47 +00:00
|
|
|
* This file Copyright (C) Mnemosyne LLC
|
2009-11-24 03:37:54 +00:00
|
|
|
*
|
2010-12-27 19:18:17 +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.
|
|
|
|
*
|
2010-01-14 14:20:49 +00:00
|
|
|
* $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"
|
|
|
|
|
2010-01-19 19:37:00 +00:00
|
|
|
/** @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;
|
|
|
|
|
2011-02-23 03:54:04 +00:00
|
|
|
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
|
|
|
|
2011-02-21 01:40:19 +00:00
|
|
|
void tr_bitsetSetHaveAll( tr_bitset * b );
|
|
|
|
void tr_bitsetSetHaveNone( tr_bitset * b );
|
2009-11-24 03:37:54 +00:00
|
|
|
|
2011-02-23 03:54:04 +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
|
|
|
|
2011-02-21 01:40:19 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
2009-11-24 03:37:54 +00:00
|
|
|
|
2011-02-21 01:40:19 +00:00
|
|
|
double tr_bitsetPercent( const tr_bitset * b );
|
2009-11-24 03:37:54 +00:00
|
|
|
|
2011-02-21 01:40:19 +00:00
|
|
|
tr_bool tr_bitsetHas( const tr_bitset * b, const size_t nth );
|
2011-02-24 01:50:35 +00:00
|
|
|
tr_bool tr_bitsetHasSet( const tr_bitset * b, const tr_bitset * compare );
|
2011-02-23 03:54:04 +00:00
|
|
|
size_t tr_bitsetCountRange( const tr_bitset * b, const size_t begin, const size_t end );
|
2009-11-24 03:37:54 +00:00
|
|
|
|
2011-02-21 01:40:19 +00:00
|
|
|
void tr_bitsetOr( tr_bitfield * a, const tr_bitset * b );
|
2009-11-24 03:37:54 +00:00
|
|
|
|
|
|
|
#endif
|