Skip to content

Add clear() method to SimpleCollector #725

@tigercosmos

Description

@tigercosmos

Context

In PR #712, World::clear() needs to reset m_bare_segment_indices (a SimpleCollector<size_t>). Since SimpleCollector does not provide a clear() method, the current workaround is to reassign a default-constructed instance:

// TODO: SimpleCollector should have a `clear()` method.
m_bare_segment_indices = SimpleCollector<size_t>();

See: #712 (comment)

Proposal

Add a clear() method to SimpleCollector (in cpp/modmesh/buffer/SimpleCollector.hpp) that resets its internal state (size back to 0, and optionally releases or reuses allocated memory).

This would allow callers to write m_bare_segment_indices.clear() instead of reassigning a new object.

Metadata

Metadata

Assignees

Labels

arrayMulti-dimensional array implementation

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions