Mercurial Hosting > luan
comparison src/luan/LuanTable.java @ 59:5c9cadd0acce
move standard calls from CmdLine to LuanState
git-svn-id: https://luan-java.googlecode.com/svn/trunk@60 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Mon, 07 Jan 2013 03:36:28 +0000 |
parents | 64ecb7a3aad7 |
children | f7e17cfb35f9 |
comparison
equal
deleted
inserted
replaced
58:d6c454b7f58c | 59:5c9cadd0acce |
---|---|
32 for( Object obj : set ) { | 32 for( Object obj : set ) { |
33 map.put(obj,Boolean.TRUE); | 33 map.put(obj,Boolean.TRUE); |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 boolean isList() { | 37 public boolean isList() { |
38 return map==null || map.isEmpty(); | 38 return map==null || map.isEmpty(); |
39 } | 39 } |
40 | 40 |
41 List<Object> asList() { | 41 public List<Object> asList() { |
42 return list!=null ? list : Collections.emptyList(); | 42 return list!=null ? list : Collections.emptyList(); |
43 } | 43 } |
44 | 44 |
45 Map<Object,Object> asMap() { | 45 public Map<Object,Object> asMap() { |
46 if( list == null || list.isEmpty() ) | 46 if( list == null || list.isEmpty() ) |
47 return map!=null ? map : Collections.emptyMap(); | 47 return map!=null ? map : Collections.emptyMap(); |
48 Map<Object,Object> rtn = map!=null ? new HashMap<Object,Object>(map) : new HashMap<Object,Object>(); | 48 Map<Object,Object> rtn = map!=null ? new HashMap<Object,Object>(map) : new HashMap<Object,Object>(); |
49 for( ListIterator iter = list.listIterator(); iter.hasNext(); ) { | 49 for( ListIterator iter = list.listIterator(); iter.hasNext(); ) { |
50 int i = iter.nextIndex(); | 50 int i = iter.nextIndex(); |
51 rtn.put(i+1,iter.next()); | 51 rtn.put(i+1,iter.next()); |
52 } | 52 } |
53 return rtn; | 53 return rtn; |
54 } | 54 } |
55 | 55 |
56 boolean isSet() { | 56 public boolean isSet() { |
57 if( list != null ) { | 57 if( list != null ) { |
58 for( Object obj : list ) { | 58 for( Object obj : list ) { |
59 if( obj!=null && !obj.equals(Boolean.TRUE) ) | 59 if( obj!=null && !obj.equals(Boolean.TRUE) ) |
60 return false; | 60 return false; |
61 } | 61 } |
67 } | 67 } |
68 } | 68 } |
69 return true; | 69 return true; |
70 } | 70 } |
71 | 71 |
72 Set<Object> asSet() { | 72 public Set<Object> asSet() { |
73 if( list == null || list.isEmpty() ) | 73 if( list == null || list.isEmpty() ) |
74 return map!=null ? map.keySet() : Collections.emptySet(); | 74 return map!=null ? map.keySet() : Collections.emptySet(); |
75 Set<Object> rtn = map!=null ? new HashSet<Object>(map.keySet()) : new HashSet<Object>(); | 75 Set<Object> rtn = map!=null ? new HashSet<Object>(map.keySet()) : new HashSet<Object>(); |
76 for( int i=1; i<=list.size(); i++ ) { | 76 for( int i=1; i<=list.size(); i++ ) { |
77 rtn.add(i); | 77 rtn.add(i); |