| Package | system.data.bags |
| Class | public class HashBag |
| Inheritance | HashBag CoreMapBag Object |
Example :
import system.data.Bag ;
import system.data.bags.HashBag ;
import system.data.Collection ;
import system.data.collections.ArrayCollection ;
import system.data.Set ;
var c1:Collection = new ArrayCollection( ["item1", "item1", "item3"] ) ;
var c2:Collection = new ArrayCollection( ["item1", "item2", "item3", "item4", "item5"] ) ;
trace ("c1 collection : " + c1) ;
trace ("c2 collection : " + c2) ;
trace ("---- create a new HashBag") ;
var bag:Bag = new HashBag() ;
trace ("---- add") ;
trace (" + bag addAll c1 : " + bag.addAll(c1)) ;
trace (" + bag addAll c2 : " + bag.addAll(c2)) ;
trace (" > bag : " + bag) ;
trace (" > bag.toSource : " + bag.toSource()) ;
trace ("---- contains") ;
trace (" > bag containsAll c2 : " + bag.containsAll(c2)) ;
trace ("---- add") ;
trace (" + bag add item2 : " + bag.add("item2") ) ;
trace (" > bag : " + bag ) ;
trace (" + bag addCopies 2xitem2 : " + bag.addCopies("item2", 2)) ;
trace (" > bag : " + bag) ;
trace ("---- remove") ;
trace (" > bag removeCopies 1 x item2 : " + bag.removeCopies("item2", 1)) ;
trace ("---- size") ;
trace (" - bag getCount item2 : " + bag.getCount("item2")) ;
trace (" > bag size : " + bag.size()) ;
trace ("---- retain") ;
trace (" > bag : " + bag) ;
trace (" > bag retainAll c1 : " + bag.retainAll(c1)) ;
trace (" > bag : " + bag) ;
trace ("----") ;
var s:Set = bag.uniqueSet() ;
trace("bag uniqueSet : " + s) ;
| Method | Defined By | ||
|---|---|---|---|
HashBag(co:Collection = null)
Creates a new HashBag instance. | HashBag | ||
![]() | 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():* [override]
Returns the shallow copy of this bag. | HashBag | ||
![]() | contains(o:*):Boolean
Returns true if this bag contains the object passed in argument. | CoreMapBag | |
![]() | containsAll(c:Collection):Boolean
Returns true if thie bag contains all object in the passed collection in argument. | CoreMapBag | |
![]() | containsAllInBag(b:Bag):Boolean
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 | |
![]() | removeAll(c:Collection):Boolean
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 | |
![]() | retainAll(c:Collection):Boolean
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 [override]
Returns the source code string representation of the object. | HashBag | ||
![]() | toString():String
Returns the string representation of this instance. | CoreMapBag | |
![]() |
Returns the Set of unique members that represent all members in the bag. | CoreMapBag | |
| HashBag | () | Constructor |
public function HashBag(co:Collection = null)Creates a new HashBag instance.
Parametersco:Collection (default = null) — a Collection to constructs a bag containing all the members of the given collection.
|
| clone | () | method |
override public function clone():*Returns the shallow copy of this bag.
Returns* — the shallow copy of this bag.
|
| toSource | () | method |
override public function toSource(indent:int = 0):StringReturns the source code string representation of the object.
Parameters
indent:int (default = 0) |
String — the source code string representation of the object.
|