6#ifndef _ZFI_ZFCoreSet_h_
7#define _ZFI_ZFCoreSet_h_
17 static _ZFP_ZFCoreSet *create(
void);
18 static void destroy(
ZF_IN _ZFP_ZFCoreSet *d);
19 _ZFP_ZFCoreSet(
void) : refCount(1) {}
20 virtual ~_ZFP_ZFCoreSet(
void) {}
22 virtual void objectInfoOfContentT(
50template<
typename T_Key,
typename T_Hash = ZFCoreMapKeyHash<T_Key>,
typename T_Equal = ZFCoreMapKeyEqual<T_Key> >
72 _ZFP_ZFCoreSet *dTmp = d;
77 if(dTmp && (--(dTmp->refCount)) == 0) {
78 _ZFP_ZFCoreSet::destroy(dTmp);
91 if(d && (--(d->refCount)) == 0) {
92 _ZFP_ZFCoreSet::destroy(d);
105 _ZFP_ZFCoreSet *dTmp = d;
107 if(--(dTmp->refCount) == 0) {
132 return d->objectCompareValue(ref.d);
155 ret += token.tokenLeft;
157 d->objectInfoOfContentT(ret, maxCount, token);
159 ret += token.tokenRight;
177 _ZFP_ZFCoreSet *dTmp = d;
219 return d ? d->count() : 0;
226 return !d || d->isEmpty();
233 return d && d->isContain(_KeyCreate(key));
260 d->add(_KeyCreate(key));
268 d->remove(_KeyCreate(key));
286 return d ? d->iter() :
zfiter();
291 return d ? d->iterFind(_KeyCreate(key)) :
zfiter();
295 return ((
const ImplKey *)d->iterValue(it))->v;
307 return d->iterAdd(_KeyCreate(key));
314 ImplKey(
ZF_IN T_Key
const &v) : v(v) {}
316 virtual zfidentity implHash(
void)
const {
return T_Hash()(v);}
317 virtual zfbool implEqual(
ZF_IN const _ZFP_ZFCoreMapKey *ref)
const {
return T_Equal()(v, ((ImplKey *)ref)->v);}
319 virtual _ZFP_ZFCoreMapKey *implCopy(
void)
const {
return zfpoolNew(ImplKey, v);}
322 static _ZFP_ZFCoreMapKey *_KeyCreate(
ZF_IN T_Key
const &v) {
327 inline void _dInit(
void) {
329 d = _ZFP_ZFCoreSet::create();
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
core map type for private use only
#define zfclassLikePOD
shows the class is not a POD type, but you may use it like a POD except memset it to 0
Definition ZFCoreTypeDef_ClassType.h:41
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfpurevirtual
dummy macro shows that a method is pure virtual method
Definition ZFCoreTypeDef_ClassType.h:68
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:198
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:202
#define zfclassNotPOD
shows the class is not a POD type, you should not memset it or declare it in stack or copy value by c...
Definition ZFCoreTypeDef_ClassType.h:48
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:214
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
_zft_zfidentity zfidentity
identity type, ensured at least 32 bit, ensured unsigned
Definition ZFCoreTypeDef_CoreType.h:225
#define zfindexMax()
(zfindex)-1, indicate a max index value, see zfindex
Definition ZFCoreTypeDef_CoreType.h:159
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
_ZFT_t_zfuint zfuint
same as unsigned int, see zfindex
Definition ZFCoreTypeDef_CoreType.h:169
#define ZFOUTPUT_TYPE_TEMPLATE(T_typenameList, T_Type, outputAction)
see ZFOUTPUT_TYPE
Definition ZFCoreTypeDef_OtherType.h:262
ZFCompareResult
compare result of two ZFObjects
Definition ZFCoreTypeDef_OtherType.h:28
@ ZFCompareUncomparable
Definition ZFCoreTypeDef_OtherType.h:29
@ ZFCompareEqual
Definition ZFCoreTypeDef_OtherType.h:31
void zftToStringT(zfstring &s, T_Type const &v)
util function to obtain object info
Definition ZFCoreTypeDef_OtherType.h:182
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define ZFM_EXPAND(...)
macro to expand a macro
Definition ZFCoreUtilMacro.h:148
#define zfpoolDelete(obj)
see zfnew
Definition ZFMemPool.h:63
#define zfpoolNew(T_Type,...)
see zfnew
Definition ZFMemPool.h:62
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
#define ZFTokenForContainerDefault()
see ZFTokenForContainer, modifyable, ZFTokenForContainerTrim by default
Definition ZFToken.h:107
core set type for private use only
Definition ZFCoreSet.h:51
void swap(zfself &ref)
swap internal data
Definition ZFCoreSet.h:175
void iterRemove(zfiter &it)
see zfiter
Definition ZFCoreSet.h:298
void objectInfoT(zfstring &ret) const
see objectInfo
Definition ZFCoreSet.h:115
zfindex count(void) const
return count
Definition ZFCoreSet.h:218
void objectInfoOfContentT(zfstring &ret, zfindex maxCount=((zfindex) -1), const ZFTokenForContainer &token=_ZFP_ZFTokenForContainerDefault) const
Definition ZFCoreSet.h:150
void removeAll(void)
remove all content
Definition ZFCoreSet.h:275
zfstring objectInfo(void) const
return object info
Definition ZFCoreSet.h:119
zfiter iterFind(const T_Key &key) const
see zfiter
Definition ZFCoreSet.h:290
zfbool isContain(const T_Key &key) const
true if contains the key
Definition ZFCoreSet.h:232
void refDelete(void)
delete reference
Definition ZFCoreSet.h:103
ZFCoreSet(const zfself &ref)
retain the ref, to copy, use copyFrom
Definition ZFCoreSet.h:63
ZFCompareResult objectCompare(zfself const &ref) const
compare by instance
Definition ZFCoreSet.h:125
void copyFrom(const zfself &ref)
copy all contents from ref, remove all before copy
Definition ZFCoreSet.h:187
zfbool isEmpty(void) const
true if empty
Definition ZFCoreSet.h:225
zfstring objectInfoOfContent(zfindex maxCount=((zfindex) -1), const ZFTokenForContainer &token=_ZFP_ZFTokenForContainerDefault) const
return contents info
Definition ZFCoreSet.h:162
void capacity(zfindex capacity)
change capacity
Definition ZFCoreSet.h:210
const T_Key & iterValue(const zfiter &it) const
see zfiter
Definition ZFCoreSet.h:294
ZFCoreSet< T_Key, T_Hash, T_Equal > zfself
typedef for self
Definition ZFCoreSet.h:54
zfself & refPrepare(void)
prepare instance to make it able to be shared between each copy
Definition ZFCoreSet.h:99
zfiter iter(void) const
see zfiter
Definition ZFCoreSet.h:285
void add(const T_Key &key)
add value
Definition ZFCoreSet.h:258
void remove(const T_Key &key)
remove or do nothing if not exist
Definition ZFCoreSet.h:266
zfiter iterAdd(const T_Key &key)
see zfiter
Definition ZFCoreSet.h:305
ZFCoreSet(void)
construct an empty set
Definition ZFCoreSet.h:59
ZFCompareResult objectCompareValue(zfself const &ref) const
compare by instance
Definition ZFCoreSet.h:129
void addFrom(const zfself &ref)
add elements from ref
Definition ZFCoreSet.h:239
util class to hold string tokens
Definition ZFToken.h:17
iterator for ZFFramework
Definition zfiter.h:40