Implementation of object Tuple
- get ( [ String name ] );
tuple.get('key');
- Number size ( );
tuple.size();
- Boolean empty ( );
tuple.empty();
- Function set ( );
var tuple = new Tuple;
tuple.set('a', 1)
('b', 2)
('c', 3)
;
- Function add ( );
tuple.add('d', 4)
('e', 5)
;
- void tie ( );
tuple.tie(tuple2);
- &remove ( );
tuple.remove('b');
- void clear ( );
tuple.clear();
-
- Get and set fields
var tuple = new Tuple;
tuple.set('a', 0)(1, 2)('function', function(param) {
alert(param);
});
tuple.get('a'); // 0
tuple.get('function')(1); // 1
tuple.get(1); // 2
tuple.get(); // {a: 1, 'function': [ object Function ], 1: 2}
-
- Add or modify fields
var tuple = new Tuple;
tuple.set('a', 1)
('b', 2)
;
tuple.add('c', 3)
('d', 4)
;
tuple.add(1, 5);
tuple.get(); // {a: 1, b: 2, c: 3, d: 4, 1: 5}
-
- // Tie fields
var tuple1 = new Tuple;
var tuple2 = new Tuple;
tuple1.set('a', 1);
tuple2.set('b', 2)
tuple1.tie(tuple2);
// tuple1: {a: 1, b: 2}
-
- Remove fields
var tuple = new Tuple;
tuple.set('a', 1)
('b', 2)
('c', 3)
;
tuple.remove('a');
// tuple: {b: 2, c: 3}
-
- Get size of fields
var tuple = new Tuple;
tuple.set('a', 1)
('b', 2)
('c', 3)
;
tuple.size(); // 3
-
- Clear the fields
var tuple = new Tuple;
tuple.set('a', 1)
('b', 2)
('c', 3)
;
tuple.clear(); // true
tuple.size(); // 0
-
- Tie
var tuple1 = new Tuple;
tuple1.set('a', 0)
var tuple2 = new Tuple;
tuple2.set('b', 1);
tuple1.tie(tuple2);
tuple1.get('b'); // 1
##_
- License This work is licensed under the MIT license