Packageas3.collections.fx
Classpublic class LinkedSetFx
InheritanceLinkedSetFx Inheritance LinkedSet Inheritance AbstractLinkedList
ImplementsILinkedSetFx

Event dispatching LinkedSet.

Dispatchs events after all changes to the set.

The dispatched event is of type FxEvents.COLLECTION_CHANGED and can be distinguished by its event.kind property.

All events of kind ITEM_xxx contain a reference to the affected item as well as an iterator returning either the affected item (add) or its successor (remove) with the first call to getNext().

The iterator returned by the particular collection event does not recognize, whether the collection has been changed during an event dispatcher sequence and may become invalid. So do not change the collection in event handlers and their scope.

Usage example
   package fx.basicusage {
    import as3.collections.fx.ILinkedSetFx;
    import as3.collections.fx.LinkedSetFx;
    import as3.collections.fx.events.FxEvents;
    import as3.collections.fx.events.SetEvent;
    import as3.collections.iterators.IIterator;
   
    import flash.display.Sprite;
   
    public class LinkedSetFxExample extends Sprite {
     
     public var theSet : ILinkedSetFx;
     
     public function LinkedSetFxExample() {
      
      theSet = new LinkedSetFx();
      theSet.addEventListener(FxEvents.COLLECTION_CHANGED, collectionChanged);
      
      // add - [3,1,2,4]
      theSet.addItem(1);
      theSet.addItem(2);
      theSet.addItemAtEnd(4);
      theSet.addItemAtStart(3); 
      
      // remove - [1]
      theSet.removeItem(2);
      theSet.removeFirstItem();
      theSet.removeLastItem();
   
      // empty theSet - []
      theSet.clear();
   
     }
     
     private function collectionChanged(event : SetEvent) : void {
      var item : = event.item;
      var iterator : IIterator = event.getIterator();
      
      switch (event.kind) {
       case FxEvents.ITEM_ADDED:
        trace ("Added item: " + item);
        trace ("Added after: " + iterator.getCurrent());
        iterator.getNext(); // returns added item
        trace ("Added before: " + iterator.getNext());
        break;
       case FxEvents.ITEM_REMOVED:
        trace ("Removed " + item);
        trace ("Removed after: " + iterator.getCurrent());
        trace ("Removed before: " + iterator.getNext());
        break;
       case FxEvents.ITEM_REPLACED:
        trace ("Replaced item: " + item);
        trace ("Replaced after: " + iterator.getCurrent());
        iterator.getNext(); // returns replaced item
        trace ("Replaced before: " + iterator.getNext());
        break;
       case FxEvents.COLLECTION_EMPTIED:
        trace ("Collection emptied");
        break;
      }
      
      trace ("----------------------");
      trace ("[" + theSet.toArray() + "]\n");
     }
    }
   }
   
   // Added item: 1
   // Added after: undefined
   // Added before: undefined
   // ----------------------
   // [1]
   
   // Added item: 2
   // Added after: 1
   // Added before: undefined
   // ----------------------
   // [1,2]
   
   // Added item: 4
   // Added after: 2
   // Added before: undefined
   // ----------------------
   // [1,2,4]
   
   // Added item: 3
   // Added after: undefined
   // Added before: 1
   // ----------------------
   // [3,1,2,4]
   
   // Removed 2
   // Removed after: 1
   // Removed before: 4
   // ----------------------
   // [3,1,4]
   
   // Removed 3
   // Removed after: undefined
   // Removed before: 1
   // ----------------------
   // [1,4]
   
   // Removed 4
   // Removed after: 1
   // Removed before: undefined
   // ----------------------
   // [1]
   
   // Collection emptied
   // ----------------------
   // []
   



Public Properties
 PropertyDefined by
  array : Array
[read-only]
LinkedSetFx
 InheritednumItems : uint
Returns the size of the linked list.
AbstractLinkedList
Protected Properties
 PropertyDefined by
 Inherited_first : LinkedNode
The first item of the linked list.
AbstractLinkedList
 Inherited_last : LinkedNode
The last item of the linked list.
AbstractLinkedList
 Inherited_map : IMap
The internal map.
LinkedSet
 Inherited_numItems : uint = 0
The size of the sequence.
AbstractLinkedList
 Inherited_pointer : AbstractPointer
The singleton linked list pointer.
AbstractLinkedList
Public Methods
 MethodDefined by
  
Creates a new LinkedSetFx.
LinkedSetFx
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
LinkedSetFx
 Inherited
addItem(item:*):Boolean
Adds an item to the set.
LinkedSet
 Inherited
addItemAtEnd(item:*):Boolean
Adds an item at the end of the linked set.
LinkedSet
 Inherited
addItemAtStart(item:*):Boolean
Adds an item in front of the linked set.
LinkedSet
  
clear():void
Removes all items from the collection.
LinkedSetFx
  
dispatchEvent(event:Event):Boolean
LinkedSetFx
 Inherited
Returns the first item of the linked list.
AbstractLinkedList
 Inherited
getIterator(cursor:uint = 0):IIterator
Returns an iterator starting at the specified position.
AbstractLinkedList
 Inherited
Returns the last item of the linked list.
AbstractLinkedList
 Inherited
Returns a pointer for the linked set.
LinkedSet
  
hasEventListener(type:String):Boolean
LinkedSetFx
 Inherited
hasItem(item:*):Boolean
Tests, if an item is contained by the set.
LinkedSet
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
LinkedSetFx
 Inherited
Removes the first item of the linked set.
LinkedSet
 Inherited
removeItem(item:*):Boolean
Removes an item from the set.
LinkedSet
 Inherited
Removes the last item of the linked set.
LinkedSet
 Inherited
reverse():void
Reverses the linked list order.
AbstractLinkedList
 Inherited
sort(comparator:IComparator):void
Sorts the linked list by a given criterion.
AbstractLinkedList
 Inherited
toArray():Array
Returns an array of all items in the present order.
AbstractLinkedList
  
toString():String
Info
LinkedSetFx
  
willTrigger(type:String):Boolean
LinkedSetFx
Protected Methods
 MethodDefined by
 Inherited
Adds the first node to an empty list.
AbstractLinkedList
 Inherited
Inserts a new node after an existing one.
AbstractLinkedList
 Inherited
Inserts a new node at the end of the sequence.
AbstractLinkedList
 Inherited
Inserts a new node at the start of the sequence.
AbstractLinkedList
 Inherited
Inserts a new node before an existing one.
AbstractLinkedList
 Inherited
Deregisters a node from the internal map.
LinkedSet
 Inherited
getNodeAt(index:uint):LinkedNode
Returns the node at a specific position.
AbstractLinkedList
 Inherited
insertionSort(comparator:IComparator):void
Insertion sort algorithm.
AbstractLinkedList
 Inherited
mergeSort(comparator:IComparator):void
Merge sort algorithm.
AbstractLinkedList
  
nodeAdded(node:LinkedNode):void
Template method to notify subclasses after a new node has been added.
LinkedSetFx
  
nodeRemoved():void
Commits the removal of the node, announced in willRemoveNode()
LinkedSetFx
 Inherited
Registers a node in the internal map.
LinkedSet
 Inherited
Unlinks the first node of the sequence.
AbstractLinkedList
 Inherited
Unlinks the last node of the sequence.
AbstractLinkedList
 Inherited
Unlinks a node and connects predecessor with successor.
AbstractLinkedList
  
Template method to notify subclasses when a node is about to be removed.
LinkedSetFx
Events
 EventSummaryDefined by
   Event type for all collection events.LinkedSetFx
Property detail
arrayproperty
array:Array  [read-only]

This property can be used as the source for data binding.

Implementation
    public function get array():Array
Constructor detail
LinkedSetFx()constructor
public function LinkedSetFx()

Creates a new LinkedSetFx.

Method detail
addEventListener()method
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

Parameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
 
priority:int (default = 0)
 
useWeakReference:Boolean (default = false)
clear()method 
public override function clear():void

Removes all items from the collection.

dispatchEvent()method 
public function dispatchEvent(event:Event):Boolean

Parameters
event:Event

Returns
Boolean
hasEventListener()method 
public function hasEventListener(type:String):Boolean

Parameters
type:String

Returns
Boolean
nodeAdded()method 
protected override function nodeAdded(node:LinkedNode):void

Template method to notify subclasses after a new node has been added.

Parameters
node:LinkedNode — The last added node.
nodeRemoved()method 
protected override function nodeRemoved():void

Commits the removal of the node, announced in willRemoveNode()

removeEventListener()method 
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void

Parameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
toString()method 
public override function toString():String

Info

Returns
String
willRemoveNode()method 
protected override function willRemoveNode(node:LinkedNode):void

Template method to notify subclasses when a node is about to be removed.

We need this node to create a reference to its predecessor. After the node has been removed, this reference would be null. The subclass is in charge to cache the node's predecessor till the node is finally removed.

Parameters
node:LinkedNode — The node that will be removed soon.
willTrigger()method 
public function willTrigger(type:String):Boolean

Parameters
type:String

Returns
Boolean
Event detail
collectionChangedevent 
Event object type: as3.collections.fx.events.SetEvent
SetEvent.type property = as3.collections.fx.events.FxEvents.COLLECTION_CHANGED

Event type for all collection events.

A collection event always is of the type COLLECTION_CHANGED. The specific change to the collection can be distinguished by examine the event's kind property. The kind of an event can be one of the following:

PropertyValue
kind The kind of change to the collection.
item The affected item.
Not set for DATA_SOURCE_REPLACED and COLLECTION_EMPTIED.
getIterator Returns an iterator pointing to the affected item (add, replace) or to its successor (remove).
Not set for DATA_SOURCE_REPLACED and COLLECTION_EMPTIED.
keyThe key of the affected item.
Only set for map events.
Not set for DATA_SOURCE_REPLACED and COLLECTION_EMPTIED.