collection

virtual class collection#(type T =  int)

virtual Defines the core functionality of a collection.

Parameter

Toptional The type of collected data.  The default is int.
Summary
collectionvirtual Defines the core functionality of a collection.
Types
da_typeThe shorthand of the dynamic array of type T.
Properties
cmpprotected A comparator to compare the elements of type T.
fmtrprotected An object that provides a function to convert the element of type T to a string.
Functions
addvirtual Adds the given element.
add_allvirtual Adds all of the elements in the given collection to this collection.
clearvirtual Removes all of the elements from this collection.
containsvirtual Returns 1 if this collection contains the specified element.
contains_allvirtual Returns 1 if this collection contains all of the elements in the specified collection.
is_emptyvirtual Returns 1 if this collection contains no elements.
get_iteratorpure virtual Returns an iterator over the elements contained in this collection.
removevirtual Removes the specified element from this collection.
remove_allvirtual Removes the elements in the given collection from this collection.
retain_allvirtual Retains only the elements in this collection that are contained in the specified collection.
sizevirtual Returns the number of elements in this collection.
to_dynamic_arrayvirtual Returns a new dynamic array that contains the elements in this collection.

Types

da_type

typedef T da_type[]

The shorthand of the dynamic array of type T.

Properties

cmp

protected comparator#(T) cmp

protected A comparator to compare the elements of type T.

fmtr

protected formatter#(T) fmtr

protected An object that provides a function to convert the element of type T to a string.

Functions

add

virtual function bit add(e)

virtual Adds the given element.

Argument

eAn element to be added.

Returns

If this collection changed as a result of the call, 1 is returned.  Otherwise, 0 is returned.

add_all

virtual function bit add_all(collection#( T ) c)

virtual Adds all of the elements in the given collection to this collection.

Argument

cA collection containing elements to be added to this collection.

Returns

If this collection changed as a result of the call, 1 is returned.  Otherwise, 0 is returned.

clear

virtual function void clear()

virtual Removes all of the elements from this collection.

Returns

None.

contains

virtual function bit contains(e)

virtual Returns 1 if this collection contains the specified element.

Argument

eAn element to be tested.

Returns

If this collection contains the specified element, returns 1.  Otherwise, returns 0.

contains_all

virtual function bit contains_all(collection#( T ) c)

virtual Returns 1 if this collection contains all of the elements in the specified collection.

Argument

cA collection to be checked.

Returns

If this collection contains all of the elements in the specified collection, returns 1.  Otherwise, returns 0.

is_empty

virtual function bit is_empty()

virtual Returns 1 if this collection contains no elements.

Returns

If this collection contains no elements, returns 1.  Otherwise, returns 0.

get_iterator

pure virtual function iterator#(T) get_iterator()

pure virtual Returns an iterator over the elements contained in this collection.

Returns

An iterator over the elements contained in this collection.

remove

virtual function bit remove(e)

virtual Removes the specified element from this collection.

Argument

eAn element to be removed.

Returns

If this collection changed as a result of the call, 1 is returned.  Otherwise, 0 is returned.

remove_all

virtual function bit remove_all(collection#( T ) c)

virtual Removes the elements in the given collection from this collection.

Argument

cA collection containing elements to be removed from this collection.

Returns

If this collection changed as a result of the call, 1 is returned.  Otherwise, 0 is returned.

retain_all

virtual function bit retain_all(collection#( T ) c)

virtual Retains only the elements in this collection that are contained in the specified collection.

Argument

cA collection containing elements to be retained in this collection.

Returns

If this collection changed as a result of the call, 1 is returned.  Otherwise, 0 is returned.

size

virtual function int size()

virtual Returns the number of elements in this collection.

Returns

The number of elements in this collection.

to_dynamic_array

virtual function da_type to_dynamic_array()

virtual Returns a new dynamic array that contains the elements in this collection.

Returns

A new dynamic array that contains the elements in this collection.

virtual class collection#(type T =  int)
virtual Defines the core functionality of a collection.
typedef T da_type[]
The shorthand of the dynamic array of type T.
protected comparator#(T) cmp
protected A comparator to compare the elements of type T.
protected formatter#(T) fmtr
protected An object that provides a function to convert the element of type T to a string.
virtual function bit add(e)
virtual Adds the given element.
virtual function bit add_all(collection#( T ) c)
virtual Adds all of the elements in the given collection to this collection.
virtual function void clear()
virtual Removes all of the elements from this collection.
virtual function bit contains(e)
virtual Returns 1 if this collection contains the specified element.
virtual function bit contains_all(collection#( T ) c)
virtual Returns 1 if this collection contains all of the elements in the specified collection.
virtual function bit is_empty()
virtual Returns 1 if this collection contains no elements.
pure virtual function iterator#(T) get_iterator()
pure virtual Returns an iterator over the elements contained in this collection.
virtual function bit remove(e)
virtual Removes the specified element from this collection.
virtual function bit remove_all(collection#( T ) c)
virtual Removes the elements in the given collection from this collection.
virtual function bit retain_all(collection#( T ) c)
virtual Retains only the elements in this collection that are contained in the specified collection.
virtual function int size()
virtual Returns the number of elements in this collection.
virtual function da_type to_dynamic_array()
virtual Returns a new dynamic array that contains the elements in this collection.