Apache Flex 4.16.0 API Reference | All Packages | All Classes | Index | Frames No Frames |
VectorList

Package | org.apache.flex.collections
Class | public class VectorList
Inheritance | VectorList flash.events.EventDispatcher
Implements | IList, IPropertyChangeNotifier

A simple implementation of IList that uses a backing Vector. This base class will not throw ItemPendingErrors but it is possible that a subclass might.

Public Properties

| Property | Defined By
--- | --- | ---
|  | length : int [read-only] Get the number of items in the list. | VectorList
|  | source : * The source vector for this VectorList. | VectorList
|  | uid : String Provides access to the unique id for this list. | VectorList

Public Methods

| Method | Defined By
--- | --- | ---
|  | VectorList(source:* = null) Construct a new VectorList using the specified Vector as its source. | VectorList
|  | addItem(item:Object):void Add the specified item to the end of the list. | VectorList
|  | addItemAt(item:Object, index:int):void Add the item at the specified index. | VectorList
|  | getItemAt(index:int, prefetch:int = 0):Object Get the item at the specified index. | VectorList
|  | getItemIndex(item:Object):int Return the index of the item if it is in the list such that getItemAt(index) == item. | VectorList
|  | itemUpdated(item:Object, property:Object = null, oldValue:Object = null, newValue:Object = null):void Notify the view that an item has been updated. | VectorList
|  | removeAll():void Remove all items from the list. | VectorList
|  | removeItem(item:Object):Boolean Removes the specified item from this list, should it exist. | VectorList
|  | removeItemAt(index:int):Object Remove the item at the specified index and return it. | VectorList
|  | setItemAt(item:Object, index:int):Object Place the item at the specified index. | VectorList
|  | toArray():Array Return an Vector that is populated in the same order as the IList implementation. | VectorList
|  | toString():String [override] Pretty prints the contents of this VectorList to a string and returns it. | VectorList

Protected Methods

| Method | Defined By
--- | --- | ---
|  | itemUpdateHandler(event:PropertyChangeEvent):void Called whenever any of the contained items in the list fires a PropertyChangeEvent. | VectorList
|  | startTrackUpdates(item:Object):void If the item is an IEventDispatcher watch it for updates. | VectorList
|  | stopTrackUpdates(item:Object):void If the item is an IEventDispatcher stop watching it for updates. | VectorList

Events

| Event | Summary | Defined By
--- | --- | --- | ---
|  | collectionChange | Dispatched when the IList has been updated in some way. | VectorList

Property Detail

length | property

`length:int` [read-only]

Get the number of items in the list. An VectorList should always know its length so it shouldn't return -1, though a subclass may override that behavior.

Implementation
`public function get length():int`

source | property |

`source:*`

The source vector for this VectorList. Any changes done through the IList interface will be reflected in the source Vector. If no source Vector was supplied the VectorList will create one internally. Changes made directly to the underlying Vector (e.g., calling `theList.source.pop()` will not cause `CollectionEvents` to be dispatched.

Implementation
`public function get source():*`
`public function set source(value:any):void`

uid | property |

`uid:String`

Provides access to the unique id for this list.

Implementation
`public function get uid():String`
`public function set uid(value:String):void`
Constructor Detail

VectorList | () | Constructor

`public function VectorList(source:* = null)`

Construct a new VectorList using the specified Vector as its source. If no source is specified an empty Vector of type will be used.

Parameters

| `source:*` (default = `null`)``

Method Detail

addItem | () | method

`public function addItem(item:Object):void`

Add the specified item to the end of the list. Equivalent to addItemAt(item, length);

Parameters

| `item:Object` — the item to add

addItemAt | () | method |

`public function addItemAt(item:Object, index:int):void`

Add the item at the specified index. Any item that was after this index is moved out by one.

Parameters

| `item:Object` — the item to place at the index
| `index:int` — the index at which to place the item

Throws

| `RangeError` — if index is less than 0 or greater than the length

getItemAt | () | method |

`public function getItemAt(index:int, prefetch:int = 0):Object`

Get the item at the specified index.

Parameters

| `index:int` — the index in the list from which to retrieve the item
| `prefetch:int` (default = `0`)`` — used in this implementation at this time

Returns

| `Object` — the item at that index, null if there is none

Throws

| `RangeError` — if the index less than 0 or index >= length

getItemIndex | () | method |

`public function getItemIndex(item:Object):int`

Return the index of the item if it is in the list such that getItemAt(index) == item. Note that in this implementation the search is linear and is therefore O(n).

Parameters

| `item:Object` — the item to find

Returns

| `int` — the index of the item, -1 if the item is not in the list.

itemUpdated | () | method |

`public function itemUpdated(item:Object, property:Object = null, oldValue:Object = null, newValue:Object = null):void`

Notify the view that an item has been updated. This is useful if the contents of the view do not implement `IEventDispatcher`. If a property is specified the view may be able to optimize its notification mechanism. Otherwise it may choose to simply refresh the whole view.

Parameters

| `item:Object` — The item within the view that was updated.
| `property:Object` (default = `null`)`` — A String, QName, or int specifying the property that was updated.
| `oldValue:Object` (default = `null`)`` — The old value of that property. (If property was null, this can be the old value of the item.)
| `newValue:Object` (default = `null`)`` — The new value of that property. (If property was null, there's no need to specify this as the item is assumed to be the new value.)

See also

mx.events.CollectionEvent
mx.core.IPropertyChangeNotifier
mx.events.PropertyChangeEvent

itemUpdateHandler | () | method |

`protected function itemUpdateHandler(event:PropertyChangeEvent):void`

Called whenever any of the contained items in the list fires a `PropertyChangeEvent`. Wraps it in a CollectionEventKind.UPDATE.

Parameters

| `event:PropertyChangeEvent`

removeAll | () | method |

`public function removeAll():void`

Remove all items from the list.

removeItem | () | method |

`public function removeItem(item:Object):Boolean`

Removes the specified item from this list, should it exist.

Parameters

| `item:Object` — Object reference to the item that should be removed.

Returns

| `Boolean` — Boolean indicating if the item was removed.

removeItemAt | () | method |

`public function removeItemAt(index:int):Object`

Remove the item at the specified index and return it. Any items that were after this index are now one index earlier.

Parameters

| `index:int` — the index from which to remove the item

Returns

| `Object` — the item that was removed

Throws

| `RangeError` — is index less than 0 or index greater than or equal to length

setItemAt | () | method |

`public function setItemAt(item:Object, index:int):Object`

Place the item at the specified index. If an item was already at that index the new item will replace it and it will be returned.

Parameters

| `item:Object` — the new value for the index
| `index:int` — the index at which to place the item

Returns

| `Object` — the item that was replaced, null if none

Throws

| `RangeError` — if index is less than 0 or greater than or equal to length

startTrackUpdates | () | method |

`protected function startTrackUpdates(item:Object):void`

If the item is an IEventDispatcher watch it for updates. This is called by addItemAt and when the source is initially assigned.

Parameters

| `item:Object`

stopTrackUpdates | () | method |

`protected function stopTrackUpdates(item:Object):void`

If the item is an IEventDispatcher stop watching it for updates. This is called by removeItemAt, removeAll, and before a new source is assigned.

Parameters

| `item:Object`

toArray | () | method |

`public function toArray():Array`

Return an Vector that is populated in the same order as the IList implementation.

Returns

| `Array`

Throws

| `ItemPendingError` — if the data is not yet completely loaded from a remote location

toString | () | method |

`override public function toString():String`

Pretty prints the contents of this VectorList to a string and returns it.

Returns

| `String`

Event Detail

collectionChange | Event

Event Object Type: `mx.events.CollectionEvent`
CollectionEvent.type property = `mx.events.CollectionEvent.COLLECTION_CHANGE`

Dispatched when the IList has been updated in some way.

The CollectionEvent.COLLECTION_CHANGE constant defines the value of the `type` property of the event object for an event that is dispatched when a collection has changed.

The properties of the event object have the following values. Not all properties are meaningful for all kinds of events. See the detailed property descriptions for more information.

Property | Value
--- | ---
`bubbles` | false
`cancelable` | false
`currentTarget` | The Object that defines the event listener that handles the event. For example, if you use `myButton.addEventListener()` to register an event listener, myButton is the value of the `currentTarget`.
`items` | An Array of objects with information about the items affected by the event. The contents of this field depend on the event kind; for details see the `items` property
`kind` | The kind of event. The valid values are defined in the CollectionEventKind class as constants.
`location` | Location within the target collection of the item(s) specified in the `items` property.
`oldLocation` | the previous location in the collection of the item specified in the `items` property.
`target` | The Object that dispatched the event; it is not always the Object listening for the event. Use the `currentTarget` property to always access the Object listening for the event.
`type` | CollectionEvent.COLLECTION_CHANGE

Sun Mar 5 2017, 03:42 PM +11:00