2
[Compact] // Using compact does not compile for some reason.
3
public class NamedVector<T> {
7
public delegate bool ForeachFunc<V> (string name, V val);
9
public NamedVector (string n1, T v1,...) {
10
// allocate temporary buffer
11
var T_buf = new T[50];
12
var N_buf = new string[50];
15
var list = va_list ();
17
var tmp_name = list.arg<string?> ();
18
var tmp_val = list.arg<T?> ();
21
while (tmp_name != null && tmp_val != null) {
22
T_buf[i] = tmp_val; N_buf[i] = tmp_name;
24
tmp_name = list.arg<string?> ();
25
tmp_val = list.arg<T?> ();
28
names = new string[i];
29
for (var j = 0; j < i; j++) {
34
assert (this.names != null);
35
assert (this.values != null);
38
public Pair @get (int i) {
39
var ret_val = new Pair<string, T> (this.names[i], this.values[i]);
43
public void @foreach (ForeachFunc<T> funk) {
44
for (var i = 0; i < values.length; i++) {
45
if (!funk (names[i], values[i])) {