| 102 | }; |
| 103 | |
| 104 | template<class T, int HashCount> class CBanPool |
| 105 | { |
| 106 | public: |
| 107 | typedef T CDataType; |
| 108 | |
| 109 | CBan<CDataType> *Add(const CDataType *pData, const CBanInfo *pInfo, const CNetHash *pNetHash); |
| 110 | int Remove(CBan<CDataType> *pBan); |
| 111 | void Update(CBan<CDataType> *pBan, const CBanInfo *pInfo); |
| 112 | void Reset(); |
| 113 | |
| 114 | int Num() const { return m_CountUsed; } |
| 115 | bool IsFull() const { return m_CountUsed == MAX_BANS; } |
| 116 | |
| 117 | CBan<CDataType> *First() const { return m_pFirstUsed; } |
| 118 | CBan<CDataType> *First(const CNetHash *pNetHash) const { return m_paaHashList[pNetHash->m_HashIndex][pNetHash->m_Hash]; } |
| 119 | CBan<CDataType> *Find(const CDataType *pData, const CNetHash *pNetHash) const |
| 120 | { |
| 121 | for(CBan<CDataType> *pBan = m_paaHashList[pNetHash->m_HashIndex][pNetHash->m_Hash]; pBan; pBan = pBan->m_pHashNext) |
| 122 | { |
| 123 | if(NetComp(&pBan->m_Data, pData) == 0) |
| 124 | return pBan; |
| 125 | } |
| 126 | |
| 127 | return 0; |
| 128 | } |
| 129 | CBan<CDataType> *Get(int Index) const; |
| 130 | |
| 131 | private: |
| 132 | enum |
| 133 | { |
| 134 | MAX_BANS=1024, |
| 135 | }; |
| 136 | |
| 137 | CBan<CDataType> *m_paaHashList[HashCount][256]; |
| 138 | CBan<CDataType> m_aBans[MAX_BANS]; |
| 139 | CBan<CDataType> *m_pFirstFree; |
| 140 | CBan<CDataType> *m_pFirstUsed; |
| 141 | int m_CountUsed; |
| 142 | }; |
| 143 | |
| 144 | typedef CBanPool<NETADDR, 1> CBanAddrPool; |
| 145 | typedef CBanPool<CNetRange, 16> CBanRangePool; |
nothing calls this directly
no outgoing calls
no test coverage detected