35 template<
class T,
class V>
43 _FORCE_INLINE_ _Pair() {}
45 _FORCE_INLINE_ _Pair(
const T& p_key,
const V& p_value) {
55 _FORCE_INLINE_
int _find(
const T& p_val,
bool &r_exact)
const {
62 int high = _data.size() -1;
64 const _Pair *a=&_data[0];
68 middle = ( low + high ) / 2;
70 if( p_val < a[ middle].key ) {
72 }
else if ( a[middle].key < p_val) {
81 if (a[middle].key<p_val)
86 _FORCE_INLINE_
int _find_exact(
const T& p_val)
const {
92 int high = _data.size() -1;
94 const _Pair *a=&_data[0];
98 middle = ( low + high ) / 2;
100 if( p_val < a[ middle].key ) {
102 }
else if ( a[middle].key < p_val) {
114 int insert(
const T& p_key,
const V& p_val) {
117 int pos = _find(p_key,exact);
119 _data[pos].value=p_val;
122 _data.insert(pos,_Pair(p_key,p_val));
126 bool has(
const T& p_val)
const {
128 return _find_exact(p_val)!=-1;
131 void erase(
const T& p_val) {
133 int pos = _find_exact(p_val);
139 int find(
const T& p_val)
const {
141 return _find_exact(p_val);
145 int find_nearest(
const T& p_val)
const {
148 return _find(p_val,exact);
152 _FORCE_INLINE_
int size()
const {
return _data.size(); }
153 _FORCE_INLINE_
bool empty()
const {
return _data.empty(); }
156 const _Pair *get_array()
const {
167 const V& getv(
int p_index)
const {
169 return _data[p_index].value;
172 V& getv(
int p_index) {
174 return _data[p_index].value;
178 const T& getk(
int p_index)
const {
180 return _data[p_index].key;
183 T& getk(
int p_index) {
185 return _data[p_index].key;
189 inline const V& operator[](
const T& p_key)
const {
191 int pos = _find_exact(p_key);
193 const T& aux=*((T*)0);
194 ERR_FAIL_COND_V(pos<1,aux);
197 return _data[pos].value;
202 inline V& operator[](
const T& p_key) {
204 int pos = _find_exact(p_key);
207 pos = insert(p_key,val);
211 return _data[pos].value;