MCPcopy Create free account
hub / github.com/ceres-solver/ceres-solver / DeleteBlockInVector

Method DeleteBlockInVector

internal/ceres/problem_impl.cc:383–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

381// destroys the ordering in the interest of speed.
382template <typename Block>
383void ProblemImpl::DeleteBlockInVector(std::vector<Block*>* mutable_blocks,
384 Block* block_to_remove) {
385 CHECK_EQ((*mutable_blocks)[block_to_remove->index()], block_to_remove)
386 << "You found a Ceres bug! \n"
387 << "Block requested: " << block_to_remove->ToString() << "\n"
388 << "Block present: "
389 << (*mutable_blocks)[block_to_remove->index()]->ToString();
390
391 // Prepare the to-be-moved block for the new, lower-in-index position by
392 // setting the index to the blocks final location.
393 Block* tmp = mutable_blocks->back();
394 tmp->set_index(block_to_remove->index());
395
396 // Overwrite the to-be-deleted residual block with the one at the end.
397 (*mutable_blocks)[block_to_remove->index()] = tmp;
398
399 DeleteBlock(block_to_remove);
400
401 // The block is gone so shrink the vector of blocks accordingly.
402 mutable_blocks->pop_back();
403}
404
405void ProblemImpl::RemoveResidualBlock(ResidualBlock* residual_block) {
406 CHECK(residual_block != nullptr);

Callers

nothing calls this directly

Calls 3

indexMethod · 0.80
ToStringMethod · 0.80
backMethod · 0.80

Tested by

no test coverage detected