Skip to content

Modern Array Clear

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Array › Array Container › Clear

Clear

Removes every element but keeps the allocated room.

Syntax

Clear( )

Notes

  • O(n) — drops elements, KEEPS capacity

Examples

#import "std/containers"
using containers

dim v as Array( of ustring )
v.Push( "a" ) : v.Push( "b" )

v.Clear( )
print v.Count            '' 0
print v.Capacity         '' 8 -- the capacity is KEPT, so a refill loop
                         '' does not reallocate

'' The slots are reset, so a T holding a resource releases it now rather
'' than at the array's destruction

Library: Array Container
Category: Array
Documented under: Members

Clone this wiki locally