| 305 | } |
| 306 | |
| 307 | size_t insert(const std::vector<node_t> &siblings) |
| 308 | { |
| 309 | if (error_ < 0) |
| 310 | return 0; |
| 311 | |
| 312 | size_t begin = 0; |
| 313 | size_t pos = _max((size_t)siblings[0].code + 1, next_check_pos_) - 1; |
| 314 | size_t nonzero_num = 0; |
| 315 | int first = 0; |
| 316 | |
| 317 | if (alloc_size_ <= pos) |
| 318 | resize(pos + 1); |
| 319 | |
| 320 | while (true) |
| 321 | { |
| 322 | next: |
| 323 | ++pos; |
| 324 | |
| 325 | if (alloc_size_ <= pos) |
| 326 | resize(pos + 1); |
| 327 | |
| 328 | if (array_[pos].check) |
| 329 | { |
| 330 | ++nonzero_num; |
| 331 | continue; |
| 332 | } |
| 333 | else if (!first) |
| 334 | { |
| 335 | next_check_pos_ = pos; |
| 336 | first = 1; |
| 337 | } |
| 338 | |
| 339 | begin = pos - siblings[0].code; |
| 340 | if (alloc_size_ <= (begin + siblings[siblings.size() - 1].code)) |
| 341 | resize(static_cast<size_t>(alloc_size_ * |
| 342 | _max(1.05, 1.0 * key_size_ / progress_))); |
| 343 | |
| 344 | if (used_[begin]) |
| 345 | continue; |
| 346 | |
| 347 | for (size_t i = 1; i < siblings.size(); ++i) |
| 348 | if (array_[begin + siblings[i].code].check != 0) |
| 349 | goto next; |
| 350 | |
| 351 | break; |
| 352 | } |
| 353 | |
| 354 | if (1.0 * nonzero_num / (pos - next_check_pos_ + 1) >= 0.95) |
| 355 | next_check_pos_ = pos; |
| 356 | |
| 357 | used_[begin] = 1; |
| 358 | size_ = _max(size_, begin + static_cast<size_t>(siblings[siblings.size() - 1].code + 1)); |
| 359 | |
| 360 | for (size_t i = 0; i < siblings.size(); ++i) |
| 361 | array_[begin + siblings[i].code].check = begin; |
| 362 | |
| 363 | try |
| 364 | { |
no test coverage detected