Mercurial Hosting > luan
comparison src/luan/LuanTable.java @ 1464:465b4a0dae4a
empty list vs map
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 03 Apr 2020 10:04:52 -0600 |
parents | 851b9a48cc44 |
children | 2e8a5df45d56 |
comparison
equal
deleted
inserted
replaced
1463:fb003c4003dd | 1464:465b4a0dae4a |
---|---|
26 this.luan = luan; | 26 this.luan = luan; |
27 } | 27 } |
28 | 28 |
29 public LuanTable(Luan luan,List list){ | 29 public LuanTable(Luan luan,List list){ |
30 this.luan = luan; | 30 this.luan = luan; |
31 list(); | |
31 int n = list.size(); | 32 int n = list.size(); |
32 for( int i=0; i<n; i++ ) { | 33 for( int i=0; i<n; i++ ) { |
33 Object val = list.get(i); | 34 Object val = list.get(i); |
34 if( val != null ) | 35 if( val != null ) |
35 rawPut2(i+1,val); | 36 rawPut2(i+1,val); |
119 clone.closure = (LuanClosure)cloner.clone(closure); | 120 clone.closure = (LuanClosure)cloner.clone(closure); |
120 } | 121 } |
121 | 122 |
122 public boolean isList() { | 123 public boolean isList() { |
123 return map==null || map.isEmpty(); | 124 return map==null || map.isEmpty(); |
125 } | |
126 | |
127 boolean isMap() { | |
128 return map!=null || list==null; | |
124 } | 129 } |
125 | 130 |
126 public List<Object> asList() { | 131 public List<Object> asList() { |
127 check(); | 132 check(); |
128 return list!=null ? list : Collections.emptyList(); | 133 return list!=null ? list : Collections.emptyList(); |
548 } | 553 } |
549 | 554 |
550 public static void setSecurity(LuanTable tbl,String security) { | 555 public static void setSecurity(LuanTable tbl,String security) { |
551 tbl.security = security; | 556 tbl.security = security; |
552 } | 557 } |
558 | |
559 public static void debug(LuanTable table) { | |
560 System.out.println("isMap "+table.isMap()); | |
561 } | |
553 } | 562 } |