Packagesystem.data.bags
Classpublic class CoreMapBag
InheritanceCoreMapBag Inheritance Object
Implements Bag
Subclasses ArrayBag, HashBag

This class provides a skeletal implementation of the Bag interface, to minimize the effort required to implement this interface.

To implement a bag, the programmer needs only to extend this class and provide implementations for the cursor, insert and size methods. For supporting the removal of elements, the cursor returned by the cursor method must additionally implement its remove method.



Public Properties
 PropertyDefined By
  modCount : int
This property is a protector used in the BagIterator object of this bag.
CoreMapBag
Public Methods
 MethodDefined By
  
CoreMapBag(map:Map = null, co:Collection = null)
Creates a new CoreMapBag instance.
CoreMapBag
  
add(o:*):Boolean
Add one copy of the given object to the bag and keep a count.
CoreMapBag
  
addAll(c:Collection):Boolean
Insert all elements represented in the given collection.
CoreMapBag
  
addCopies(o:*, nCopies:uint):Boolean
Add n copies of the given object to the bag and keep a count.
CoreMapBag
  
clear():void
Removes all of the elements from this bag.
CoreMapBag
  
clone():*
Returns the shallow copy of this bag.
CoreMapBag
  
contains(o:*):Boolean
Returns true if this bag contains the object passed in argument.
CoreMapBag
  
Returns true if thie bag contains all object in the passed collection in argument.
CoreMapBag
  
Returns true if thie bag contains all object in the passed bag in argument.
CoreMapBag
  
equals(o:*):Boolean
Compares this Bag to another.
CoreMapBag
  
get(key:*):*
Unsupported by bag objects.
CoreMapBag
  
getCount(o:*):uint
Returns the count of the specified object passed in argument.
CoreMapBag
  
indexOf(o:*, fromIndex:uint = 0):int
Unsupported by bag objects.
CoreMapBag
  
isEmpty():Boolean
Returns true if the bag is empty.
CoreMapBag
  
Returns the Iterator representation of the Bag.
CoreMapBag
  
remove(o:*):*
Removes the object in argument in the bag.
CoreMapBag
  
Removes objects from the bag according to their count in the specified collection.
CoreMapBag
  
removeCopies(o:*, nCopies:uint):Boolean
Removes a specified number of copies of an object from the bag.
CoreMapBag
  
Removes any members of the bag that are not in the given collection, respecting cardinality.
CoreMapBag
  
retainAllInBag(b:Bag):Boolean
Removes any members of the bag that are not in the given bag, respecting cardinality.
CoreMapBag
  
size():uint
Returns the number of elements in this bag (its cardinality).
CoreMapBag
  
toArray():Array
Returns the array representation of the bag.
CoreMapBag
  
toSource(indent:int = 0):String
Returns the source code string representation of the object.
CoreMapBag
  
toString():String
Returns the string representation of this instance.
CoreMapBag
  
Returns the Set of unique members that represent all members in the bag.
CoreMapBag
Property Detail
modCountproperty
modCount:int

This property is a protector used in the BagIterator object of this bag.


Implementation
    public function get modCount():int
    public function set modCount(value:int):void
Constructor Detail
CoreMapBag()Constructor
public function CoreMapBag(map:Map = null, co:Collection = null)

Creates a new CoreMapBag instance.

Parameters
map:Map (default = null) — a Map reference used to register all elements in the Bag.
 
co:Collection (default = null) — a Collection to constructs a bag containing all the members of the given collection.
Method Detail
add()method
public function add(o:*):Boolean

Add one copy of the given object to the bag and keep a count.

Parameters

o:*

Returns
Boolean
addAll()method 
public function addAll(c:Collection):Boolean

Insert all elements represented in the given collection.

Parameters

c:Collection

Returns
Boolean
addCopies()method 
public function addCopies(o:*, nCopies:uint):Boolean

Add n copies of the given object to the bag and keep a count.

Parameters

o:*
 
nCopies:uint

Returns
Booleantrue if the object was not already in the uniqueSet
clear()method 
public function clear():void

Removes all of the elements from this bag.

clone()method 
public function clone():*

Returns the shallow copy of this bag.

Returns
* — the shallow copy of this bag.
contains()method 
public function contains(o:*):Boolean

Returns true if this bag contains the object passed in argument.

Parameters

o:*

Returns
Booleantrue if this bag contains the object passed in argument.
containsAll()method 
public function containsAll(c:Collection):Boolean

Returns true if thie bag contains all object in the passed collection in argument.

Parameters

c:Collection

Returns
Booleantrue if thie bag contains all object in the passed collection in argument.
containsAllInBag()method 
public function containsAllInBag(b:Bag):Boolean

Returns true if thie bag contains all object in the passed bag in argument.

Parameters

b:Bag

Returns
Booleantrue if thie bag contains all object in the passed bag in argument.
equals()method 
public function equals(o:*):Boolean

Compares this Bag to another. This Bag equals another Bag if it contains the same number of occurrences of the same elements.

Parameters

o:* — the Bag to compare to.

Returns
Boolean — true if equal.
get()method 
public function get(key:*):*

Unsupported by bag objects.

Parameters

key:*

Returns
*

Throws
IllegalOperationError — the 'get' method is unsupported with a bag object.
getCount()method 
public function getCount(o:*):uint

Returns the count of the specified object passed in argument.

Parameters

o:*

Returns
uint — the count of the specified object passed in argument.
indexOf()method 
public function indexOf(o:*, fromIndex:uint = 0):int

Unsupported by bag objects.

Parameters

o:*
 
fromIndex:uint (default = 0)

Returns
int

Throws
IllegalOperationError — the 'indexOf' method is unsupported with a bag object.
isEmpty()method 
public function isEmpty():Boolean

Returns true if the bag is empty.

Returns
Booleantrue if the bag is empty.
iterator()method 
public function iterator():Iterator

Returns the Iterator representation of the Bag.

Returns
Iterator — the Iterator representation of the Bag.
remove()method 
public function remove(o:*):*

Removes the object in argument in the bag.

Parameters

o:*

Returns
*
removeAll()method 
public function removeAll(c:Collection):Boolean

Removes objects from the bag according to their count in the specified collection.

Parameters

c:Collection — the collection to use.

Returns
Boolean — true if the bag changed.
removeCopies()method 
public function removeCopies(o:*, nCopies:uint):Boolean

Removes a specified number of copies of an object from the bag.

Parameters

o:* — the object to remove
 
nCopies:uint — the number of copies to remove

Returns
Boolean — true if the bag changed
retainAll()method 
public function retainAll(c:Collection):Boolean

Removes any members of the bag that are not in the given collection, respecting cardinality.

Example :

         import system.data.Collection;
         import system.data.collections.ArrayCollection;
         import system.data.bags.CoreMapBag;
         import system.data.maps.ArrayMap;
         
         var bag:CoreMapBag = new CoreMapBag( new ArrayMap() ) ;
         
         bag.add("item1") ;
         bag.add("item2") ;
         bag.add("item2") ;
         bag.add("item3") ;
         bag.add("item3") ;
         bag.add("item3") ;
         
         var col:Collection = new ArrayCollection(["item1","item2","item3"]) ;
         bag.retainAll(col) ;
         trace( bag ) ; // {1:item1,2:item2}
         

Parameters

c:Collection — the collection to retain.

Returns
Booleantrue if this call changed the collection.
retainAllInBag()method 
public function retainAllInBag(b:Bag):Boolean

Removes any members of the bag that are not in the given bag, respecting cardinality.

Parameters

b:Bag — the bag to retain.

Returns
Booleantrue if this call changed the collection.
size()method 
public function size():uint

Returns the number of elements in this bag (its cardinality).

Returns
uint — the number of elements in this bag (its cardinality).
toArray()method 
public function toArray():Array

Returns the array representation of the bag.

Returns
Array — the array representation of the bag.
toSource()method 
public function toSource(indent:int = 0):String

Returns the source code string representation of the object.

Parameters

indent:int (default = 0)

Returns
String — the source code string representation of the object.
toString()method 
public function toString():String

Returns the string representation of this instance.

Returns
String — the string representation of this instance.
uniqueSet()method 
public function uniqueSet():Set

Returns the Set of unique members that represent all members in the bag.

Returns
Set — the Set of unique members that represent all members in the bag.