try to fix some minor dropdown bugs
[potlatch2.git] / org / idmedia / as3commons / util / EntrySet.as
1 package org.idmedia.as3commons.util
2 {
3         import org.idmedia.as3commons.lang.IllegalArgumentException;
4         
5         internal class EntrySet extends AbstractSet {
6           
7           private var table:Array;
8           private var tableSize:int;
9           
10           function EntrySet() {
11             table = new Array();
12             tableSize = 0;
13           }
14           
15           override public function iterator():Iterator {
16             return new EntrySetIterator(this);  
17           }
18           
19           override public function add(object:*):Boolean {
20             if(!(object is Entry)) {
21               throw new IllegalArgumentException();     
22             }
23         
24             if(!contains(object)) {
25               table.push(object);
26               tableSize++;
27               return true;      
28             }
29             return false;
30           }
31           
32           override public function remove(entry:* = null):Boolean {
33             for(var i:int = 0;i < tableSize; i++) {
34               if(Entry(entry).equals(table[i])) {
35                 table.splice(i, 1);
36                 tableSize--;
37                 return true;    
38               } 
39             }
40             return false;
41           }
42           
43           public function get(index:int):* {
44             return table[index];
45           }
46           
47           public function removeEntryForKey(key:*):Entry {
48             var e:Entry = null;
49             for(var i:int = 0;i < tableSize; i++) {
50               if(Entry(table[i]).getKey() === key) {
51                 e = table[i];
52                 table.splice(i, 1);
53                 tableSize--;
54                 return e;       
55               } 
56             }
57             return e;
58           }
59           
60           override public function size():int {
61             return tableSize;   
62           }
63         }
64
65 }