コード例 #1
0
ファイル: app.cpp プロジェクト: FaddliLWibowo/wiselib
		/**
		 * Insert into dictionary, track in `inserts`.
		 */
		void insert(char* s) {
			Dictionary::key_type k = dictionary_.insert((block_data_t*)s);
			int l = strlen(s) + 1;
			int pos = 0;
			for(Inserts::iterator iter = inserts.begin(); iter != inserts.end(); ++iter, pos++) {
				if(memcmp(*iter, s, l - 1) == 0) {
					assert(used_keys[pos] == k);
					counts[pos]++;
					return;
				}
			}

			char *s2 = new char[l];
			memcpy(s2, s, l);
			used_keys.push_back(k);
			inserts.push_back(s2);
			counts.push_back(1);
		}