Collections solution with JsJava(jsjava-collections-2.0.js):

As we known,array object in Javascript is very useful for data structure.Array object can be widely used for collections such as list,set,hashtable,stack,iterator and so on.But there are not standard collections object in Javascript,so it's not convenient for data storage.

JsJava offer almost all of the collections:

1, BitSet, in the directory jsjava.util
Each component of the bit set has a boolean value,true or false.You can operate the bit set with AND,OR,XOR and other logic operation.Example as follows: <script src="jsjava-2.0.js"></script> <script> var bs1=new BitSet(); var bs2=new BitSet(); bs1.set(2); bs2.set(3); bs1.andNot(bs2); </script>
2, Hashtable, in the directory jsjava.util
Hashtable is very usefull for data storage.Example as follows: <script src="jsjava-2.0.js"></script> <script> var h=new Hashtable(); h.put("a","b"); h.put("c","d"); document.write(h.get("c")+"<br>"); document.write(h.get("none")+"<br>"); document.write(h.containsKey("a")); </script>
3, Iterator, in the directory jsjava.util
An iterator over a collection.Example as follows: <script src="jsjava-2.0.js"></script> <script> var list=new ArrayList(); list.add("a"); list.add("b"); list.add("c"); var it=list.iterator(); while(it.hasNext()){ document.write(it.next()+"&nbsp;"); } document.write("<br>"); it.moveTo(0); while(it.hasNext()){ document.write(it.next()+"&nbsp;"); } </script>
4, List, in the directory jsjava.util
A list is an ordered collection which allows duplicate elements.Example as follows: <script src="jsjava-2.0.js"></script> <script> var list=new ArrayList(); list.add(new Date()); list.add("test"); list.add(new Integer(5)); var date=list.get(0); document.write((date instanceof Date)+"<br>"); var i=list.get(2); document.write(i instanceof Integer); </script>
5, Properties, in the directory jsjava.util
A properties is a hashtable,and its key and value are both string.Example as follows: <script src="jsjava-2.0.js"></script> <script> var p=new Properties(); p.setProperty("a","1"); document.write(p.getProperty("a")+"<br>"); p.set("b",new Date()); document.write(p.getProperty("b")+"<br>"); document.write(p.get("b")); </script>
6, Set, in the directory jsjava.util
A set is a list which allows no duplicate elements.Example as follows: <script src="jsjava-2.0.js"></script> <script> var s=new HashSet(); var a=["a","b","a","b","c"]; s.addArray(a); document.write(s); </script> The display is a,b,c
7, Stack, in the directory jsjava.util
Stack is widely used in many scenes.Example as follows: <script src="jsjava-2.0.js"></script> <script> var s=new Stack(); s.push("cat"); s.push("dog"); document.write(s.pop()); </script> The display is dog

With JsJava collections framework,we can meet the requirements of data storage and operation better.