nx.data.Collection - Next UI Toolkit

#

API Docs for: trial
Show: Inherited Protected Private Deprecated

# nx.data.Collection Class

Extends nx.Iterable
Module: nx.data

## Constructor

### `nx.data.Collection`

(

- `iter`

)

#### Parameters:

- `iter` Object

- Index
- Methods
- Properties

## Item Index

### Methods

- add
- addRange
- clear
- contains
- each
- getItem
- getRange
- indexOf
- insert
- insertRange
- lastIndexOf
- remove
- removeAt
- sort
- toArray
- toggle

### Properties

- count
- length

## Methods

### `add`

(

- `item`

)

Add an item.

#### Parameters:

- `item` Object

#### Returns:

added item. Null if fail to add, e.g. duplicated add into unique collection.

### `addRange`

(

- `iter`

)

Add multiple items. Will avoid duplicated items for unique collection.

#### Parameters:

- `iter` Object

#### Returns:

array of added items.

### `clear`

()

#### Returns:

:

### `contains`

(

- `item`

)
Boolean

#### Parameters:

- `item` Object

#### Returns:

Boolean:

### `each`

(

- `callback`
- `context`

)

Inherited from nx.Iterable

#### Parameters:

- `callback` Object
- `context` Object

### `getItem`

(

- `index`

)

#### Parameters:

- `index` Object

#### Returns:

:

### `getRange`

(

- `index`
- `count`

)
Collection

#### Parameters:

- `index` Object
- `count` Object

#### Returns:

Collection:

### `indexOf`

(

- `item`

)

Get the first index the given item appears in the collection, -1 if not found.

#### Parameters:

- `item` Object

#### Returns:

:

### `insert`

(

- `item`
- `index`

)

#### Parameters:

- `item` Object
- `index` Object

### `insertRange`

(

- `index`
- `iter`

)

#### Parameters:

- `index` Object
- `iter` Object

#### Returns:

:

### `lastIndexOf`

(

- `item`

)

#### Parameters:

- `item` Object

#### Returns:

:

### `remove`

(

- `item`

)

#### Parameters:

- `item` Object

#### Returns:

Removed item's index, -1 if not found.

### `removeAt`

(

- `index`

)

#### Parameters:

- `index` Object

#### Returns:

Removed item.

### `sort`

(

- `comp`

)
Array

#### Parameters:

- `comp` Object

#### Returns:

Array:

### `toArray`

() Array

Inherited from nx.Iterable

#### Returns:

Array:

### `toggle`

(

- `item`

)

Toggle item's existence.

#### Parameters:

- `item` Object

## Properties

### `count`

Number

Inherited from nx.Iterable

### `length`

Number