# buffer

* `new(size: usize)` - creates a new buffer with the specified capacity.
* `get_events()` - returns a mutable reference to the buffer's event handler.
* `add<T: Any>(object: T)` - adds the object to the buffer if there is space, returning an error if the buffer is full.
* `get<T: Any>(index: usize)` - retrieves the object at the given index, returning a reference to it without modifying the buffer.
* `peek<T: Any>(index: usize)` - inspects the object at the given index without removing or modifying it.
* `remove(index: usize)` - removes and returns the object at the given index.
* `remove_by_type<T: Any>()` - removes and returns the first object of the specified type from the buffer, if found.
* `swap(index1: usize, index2: usize)` - swaps the objects at the given indices.
* `clear()` - removes all objects from the buffer.
* `len()` - returns the number of objects currently in the buffer.
* `is_full()` - returns `true` if the buffer has reached its maximum capacity.
* `is_empty()` - returns `true` if the buffer is empty.
* `contains<T: Any>()` - returns `true` if the buffer contains an object of the specified type.
* `iter()` - returns an iterator over the objects in the buffer.
* `items_of_type<T: Any>()` - returns a list of references to all objects of the specified type.
* `capacity()` - returns the maximum number of objects the buffer can hold.
* `resize(new_size: usize)` - changes the buffer's capacity to the specified size, returning an error if the new size is smaller than the current number of objects.
* `count_by_type<T: Any>()` - returns the number of objects of the specified type in the buffer.
