acl/lib_acl_cpp/include/acl_cpp/stdlib/bitmap.hpp

108 lines
2.0 KiB
C++
Raw Normal View History

#pragma once
#include "noncopyable.hpp"
namespace acl {
class bitmap : public noncopyable
{
public:
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param buf {const void*} Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>λӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param len {size_} buf λӳ<EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
bitmap(const void* buf, size_t len);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param len {size_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD>λӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
bitmap(size_t len);
2020-05-19 12:03:24 +08:00
~bitmap(void);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param n {size_t}
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ֵԽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
bool bit_set(size_t n);
/**
* <EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param n {size_t}
* @return {bool} <EFBFBD>ж<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
2020-05-19 12:03:24 +08:00
bool bit_isset(size_t n) const;
/**
* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD>
* @param n {size_t}
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> false <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ֵԽ<EFBFBD><EFBFBD><EFBFBD>򲻴<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
bool bit_unset(size_t n);
/**
* <EFBFBD><EFBFBD>bitmap<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>buf<EFBFBD><EFBFBD>
* @param buf {void*}<EFBFBD><EFBFBD><EFBFBD>ſ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param len {size_t} buf<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󳤶<EFBFBD>
* @return {size_t} <EFBFBD><EFBFBD><EFBFBD>سɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>ȣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0 <EFBFBD><EFBFBD>ʾ buf ̫С
*/
2020-05-19 12:03:24 +08:00
size_t tobuf(void* buf, size_t len) const;
/**
* <EFBFBD><EFBFBD>buf<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰbitmap<EFBFBD><EFBFBD>Ϣ
* @param buf {const void*} Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>bitmap<EFBFBD><EFBFBD>Ϣ
* @param len {size_t} buf<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>
* @return true <EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>falseʧ<EFBFBD><EFBFBD>
*/
bool frombuf(const void* buf, size_t len);
/**
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><EFBFBD>bitmapΪ 0
*/
void reset(void);
/**
2020-05-19 12:03:24 +08:00
* <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰλӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>λ<EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD>
* @return {size_t}
*/
2020-05-19 12:03:24 +08:00
size_t size(void) const;
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD>ֽڣ<EFBFBD>
*/
size_t space(void) const;
/**
* <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>õĸ<EFBFBD><EFBFBD><EFBFBD>
* @return {size_t}
*/
2020-05-19 12:03:24 +08:00
size_t count(void) const;
/**
* <EFBFBD><EFBFBD>ǰbitmap<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {bool}
*/
2020-05-19 12:03:24 +08:00
bool full(void) const;
2020-05-19 18:20:48 +08:00
public:
const unsigned char* get_bmp(void) const {
return bmp_;
}
unsigned char* get_bmp(void) {
return bmp_;
}
private:
unsigned char *bmp_;
size_t size_;
size_t count_;
//<2F><><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>count<6E><74><EFBFBD><EFBFBD>
void recount(void);
};
} // namespace acl