Mercurial Hosting > luan
comparison core/src/luan/modules/TableLuan.java @ 431:3ffe8ba5b297
TableLuan cleanup
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 02 May 2015 21:12:48 -0600 |
parents | dae264ad6a7b |
children | d9df6d6cb927 |
comparison
equal
deleted
inserted
replaced
430:f28320fd671d | 431:3ffe8ba5b297 |
---|---|
33 } | 33 } |
34 return buf.toString(); | 34 return buf.toString(); |
35 } | 35 } |
36 | 36 |
37 public static void insert(LuanTable list,int pos,Object value){ | 37 public static void insert(LuanTable list,int pos,Object value){ |
38 list.insert(pos,value); | 38 list.rawInsert(pos,value); |
39 } | 39 } |
40 | 40 |
41 public static Object remove(LuanTable list,int pos) { | 41 public static Object remove(LuanTable list,int pos) { |
42 return list.remove(pos); | 42 return list.rawRemove(pos); |
43 } | 43 } |
44 | 44 |
45 private static interface LessThan { | 45 private static interface LessThan { |
46 public boolean isLessThan(Object o1,Object o2); | 46 public boolean isLessThan(Object o1,Object o2); |
47 } | 47 } |
68 } | 68 } |
69 } | 69 } |
70 }; | 70 }; |
71 } | 71 } |
72 try { | 72 try { |
73 list.sort( new Comparator<Object>() { | 73 list.rawSort( new Comparator<Object>() { |
74 public int compare(Object o1,Object o2) { | 74 public int compare(Object o1,Object o2) { |
75 return lt.isLessThan(o1,o2) ? -1 : lt.isLessThan(o2,o1) ? 1 : 0; | 75 return lt.isLessThan(o1,o2) ? -1 : lt.isLessThan(o2,o1) ? 1 : 0; |
76 } | 76 } |
77 } ); | 77 } ); |
78 } catch(LuanRuntimeException e) { | 78 } catch(LuanRuntimeException e) { |
86 for( int i=0; i<args.length; i++ ) { | 86 for( int i=0; i<args.length; i++ ) { |
87 Object v = args[i]; | 87 Object v = args[i]; |
88 if( v==null ) { | 88 if( v==null ) { |
89 hasNull = true; | 89 hasNull = true; |
90 } else if( !hasNull ) { | 90 } else if( !hasNull ) { |
91 tbl.add(v); | 91 tbl.rawAdd(v); |
92 } else { | 92 } else { |
93 tbl.rawPut(i+1,v); | 93 tbl.rawPut(i+1,v); |
94 } | 94 } |
95 } | 95 } |
96 tbl.rawPut( "n", args.length ); | 96 tbl.rawPut( "n", args.length ); |
106 } | 106 } |
107 return list.toArray(); | 107 return list.toArray(); |
108 } | 108 } |
109 | 109 |
110 public static LuanTable sub_list(LuanTable list,int from,int to) { | 110 public static LuanTable sub_list(LuanTable list,int from,int to) { |
111 return list.subList(from,to); | 111 return list.rawSubList(from,to); |
112 } | 112 } |
113 | 113 |
114 public static LuanTable clone(LuanTable tbl) { | 114 public static LuanTable clone(LuanTable tbl) { |
115 return new LuanTable(tbl); | 115 return new LuanTable(tbl); |
116 } | 116 } |