Class Collection

Class used to store objects in an iterable

Source : file data/Collection.js at line 32

Constructor

new Collection ( classCollection )

The constructor

Source : file data/Collection.js at line 105

Parameters

Name Type Description
classCollection Class

The class of objects that have to be stored in the collection

Public getters and setters

readonly get first : TravelObject

The first object of the Collection

Source : file data/Collection.js at line 290

readonly get iterator : CollectionIterator

An iterator on the Collection. See CollectionIterator

Source : file data/Collection.js at line 298

get jsonObject : Array

An Array with the objects in the collection

Source : file data/Collection.js at line 321

set jsonObject

Source : file data/Collection.js at line 331

readonly get last : TravelObject

The last object of the Collection

Source : file data/Collection.js at line 307

readonly get length : Number

The length of the Collection

Source : file data/Collection.js at line 314

Public methods

add ( object )

Add an object at the end of the collection

Source : file data/Collection.js at line 121

Parameters

Name Type Description
object TravelObject

The object to add

at ( index )

Search an object in the collection with the index

Source : file data/Collection.js at line 134

Parameters

Name Type Description
index Number

The position of the desired object in the array

Returns

The object at the position or null if not found
Type : null or Object

forEach ( funct )

Executes a function on each object of the Collection and returns the final result

Source : file data/Collection.js at line 143

Parameters

Name Type Description
funct Function

The function to execute

getAt ( objId )

Search an object in the Collection

Source : file data/Collection.js at line 158

Parameters

Name Type Description
objId Number

The objId of the object to search

Returns

The object with the given objId or null when the object is not found
Type : TravelObject

moveTo ( objId, targetObjId, moveBefore )

Move an object near another object in the Collection

Source : file data/Collection.js at line 170

Parameters

Name Type Description
objId Number

The objId of the object to move

targetObjId Number

The objId of the object near witch the object will be moved

moveBefore Boolean

When true, the object is moved before the target, when false after the target

next ( objId, condition )

Gives the next object in the collection that fullfil a given condition

Source : file data/Collection.js at line 193

Parameters

Name Type Description
objId Number

The objId of the object from witch the search start

condition null or Function

A fonction used to compare the objects. If null, ( ) => true is used

Returns

An object or null if nothing found
Type : null or Object

previous ( objId, condition )

Gives the previous object in the collection that fullfil a given condition

Source : file data/Collection.js at line 202

Parameters

Name Type Description
objId Number

The objId of the object from witch the search start

condition null or Function

A fonction used to compare the objects. If null, ( ) => true is used

Returns

An object or null if nothing found
Type : null or Object

remove ( objId )

Remove an object from the Collection

Source : file data/Collection.js at line 209

Parameters

Name Type Description
objId Number

The objId of the object to remove

removeAll ( exceptFirstLast )

Remove all objects from the Collection

Source : file data/Collection.js at line 222

Parameters

Name Type Description
exceptFirstLast null or Boolean

When true, first and last objects are not removed

replace ( oldObjId, newObject )

Replace an object in the Collection with another object

Source : file data/Collection.js at line 237

Parameters

Name Type Description
oldObjId Number

The objId of the object to replace

newObject TravelObject

The new object

reverse ( )

Reverse the objects in the collection

Source : file data/Collection.js at line 252

sort ( compareFunction )

Sort the collection, using a function

Source : file data/Collection.js at line 259

Parameters

Name Type Description
compareFunction Function

The function to use to compare objects in the Collection

swap ( objId, swapUp )

Reverse an Object with the previous or next object in the Collection

Source : file data/Collection.js at line 268

Parameters

Name Type Description
objId Number

The objId of the object to swap

swapUp Boolean

When true the object is swapped with the previous one, when false with the next one

Private properties

#array : Array of Object

The array where objects are stored

Source : file data/Collection.js at line 39

#classCollection : Class

The class definition of objects stored in the collection

Source : file data/Collection.js at line 53

#objName : String

The class name of objects stored in the collection

Source : file data/Collection.js at line 46

Private methods

#indexOfObjId ( objId )

Return the position of an object in the Collection

Source : file data/Collection.js at line 61

Parameters

Name Type Description
objId Number

The objId of the object to locate

Returns

The position of the object in the Collection
Type : Number

#nextOrPrevious ( objId, condition, direction )

Gives the previous or next object in the collection that fullfil a given condition

Source : file data/Collection.js at line 75

Parameters

Name Type Description
objId Number

The objId of the object from witch the search start

condition null or Function

A fonction used to compare the objects. If null, ( ) => true is used

direction Number

The direction to follow. Must be NEXT or PREVIOUS

Returns

An object or null if nothing found
Type : null or Object