Skip to content

Commit

Permalink
[RUNTIME] Add clear() function in tvm::Map class
Browse files Browse the repository at this point in the history
  • Loading branch information
honghua.cao committed Apr 12, 2021
1 parent f38ae65 commit 3ca26b6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/tvm/runtime/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -2980,6 +2980,15 @@ class Map : public ObjectRef {
}
/*! \return whether array is empty */
bool empty() const { return size() == 0; }
/*! \brief Release reference to all the elements */
void clear() {
MapNode* n = GetMapNode();
if (n != nullptr) {
for (auto it = n->begin(); it != n->end(); ++it) {
CopyOnWrite()->erase(it);
}
}
}
/*!
* \brief set the Map.
* \param key The index key.
Expand Down

0 comments on commit 3ca26b6

Please sign in to comment.