Mercurial Hosting > luan
diff core/src/luan/LuanTable.java @ 431:3ffe8ba5b297
TableLuan cleanup
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 02 May 2015 21:12:48 -0600 |
parents | f28320fd671d |
children | d9df6d6cb927 |
line wrap: on
line diff
--- a/core/src/luan/LuanTable.java Sat May 02 20:35:26 2015 -0600 +++ b/core/src/luan/LuanTable.java Sat May 02 21:12:48 2015 -0600 @@ -35,23 +35,6 @@ } } - LuanTable(Map<Object,Object> map) { - map.remove(null); - for( Iterator<Object> i=map.values().iterator(); i.hasNext(); ) { - if( i.next() == null ) - i.remove(); - } - this.map = map; - } - - LuanTable(Set<Object> set) { - map = newMap(); - for( Object obj : set ) { - if( obj != null ) - map.put(obj,Boolean.TRUE); - } - } - public LuanTable(LuanTable tbl) { if( tbl.map != null && !tbl.map.isEmpty() ) this.map = new LinkedHashMap<Object,Object>(tbl.map); @@ -233,25 +216,25 @@ return list; } - public void insert(int pos,Object value) { + public void rawInsert(int pos,Object value) { if( value==null ) throw new IllegalArgumentException("can't insert a nil value"); list().add(pos-1,value); mapToList(); } - public void add(Object value) { + public void rawAdd(Object value) { if( value==null ) throw new IllegalArgumentException("can't add a nil value"); list().add(value); mapToList(); } - public Object remove(int pos) { + public Object rawRemove(int pos) { return list().remove(pos-1); } - public void sort(Comparator<Object> cmp) { + public void rawSort(Comparator<Object> cmp) { Collections.sort(list(),cmp); } @@ -306,7 +289,7 @@ }; } - public LuanTable subList(int from,int to) { + public LuanTable rawSubList(int from,int to) { LuanTable tbl = shallowClone(); tbl.list = new ArrayList<Object>(list().subList(from-1,to-1)); return tbl; @@ -336,14 +319,10 @@ // from AbstractLuanTable - protected final Map<Object,Object> newMap() { + private Map<Object,Object> newMap() { return new LinkedHashMap<Object,Object>(); } - public boolean isEmpty() { - return isList() && length()==0; - } - public boolean isSet() { for( Map.Entry<Object,Object> entry : this ) { if( !entry.getValue().equals(Boolean.TRUE) )