#include <limits.h>␍␊ |
␍␊ |
#include "ptypes.h"␍␊ |
#include "pstreams.h"␍␊ |
␍␊ |
␍␊ |
PTYPES_BEGIN␍␊ |
␍␊ |
bool ptdecl anext(const tparray& a, int& i, variant& val)␍␊ |
{␍␊ |
␉variant t;␍␊ |
␉return anext(a, i, val, t);␍␊ |
}␍␊ |
␍␊ |
bool ptdecl anext(const tparray& a, int& i, variant& val, variant & key)␍␊ |
{␍␊ |
␉if (a._keys.get_count() == i)␍␊ |
␉//if (a._vals.size() == i)␍␊ |
␉//if (a._vals.get_count() == i)␍␊ |
␉if (alength(a._vals) == i)␍␊ |
␉{␍␊ |
␉␉return false;␍␊ |
␉}␍␊ |
␉else␍␊ |
␉{␍␊ |
␉␉val = a._vals[i];␍␊ |
␉␉key = a._keys[i];␍␊ |
␉␉val = a._vals[(large)i];␍␊ |
␉␉i++;␍␊ |
␉␉return true;␍␊ |
␉}␍␊ |
}␍␊ |
␍␊ |
bool ptdecl anext(const tparray& a, int& i, variant& val, variant & key)␍␊ |
{␍␊ |
␉//if (a._keys.size() == i)␍␊ |
␉//if (a._keys.get_count() == i)␍␊ |
␉if (alength(a._keys) == i)␍␊ |
␉{␍␊ |
␉␉return false;␍␊ |
␉}␍␊ |
␉else␍␊ |
␉{␍␊ |
␉␉val = a._vals[(large)i];␍␊ |
␉␉key = a._keys[(large)i];␍␊ |
␉␉i++;␍␊ |
␉␉return true;␍␊ |
␉}␍␊ |
|
␉if (t.tag == ARR_NULL || t.tag == ARR_LIST)␍␊ |
␉{␍␊ |
␉␉t.tag = ARR_LIST;␍␊ |
␉␉t._vals.add(val);␍␊ |
␉␉//pout.put("here1");␍␊ |
␉␉//t._vals.push_back(val);␍␊ |
␉␉add(t._vals, val);␍␊ |
␉␉//t._vals.add(val);␍␊ |
␉␉//pout.put("here2");␍␊ |
␉}␍␊ |
␍␊ |
␉//else drop it␍␊ |
|
␉if (t.tag == ARR_NULL || t.tag == ARR_ASSOCIATIVE)␍␊ |
␉{␍␊ |
␉␉t.tag = ARR_ASSOCIATIVE;␍␊ |
␉␉t._vals.add(val);␍␊ |
␉␉t._keys.add(key);␍␊ |
␉␉add(t._vals, val);␍␊ |
␉␉add(t._keys, key);␍␊ |
␉␉//t._vals.add(val);␍␊ |
␉␉//t._keys.add(key);␍␊ |
␉␉//t._vals.push_back(val);␍␊ |
␉␉//t._keys.push_back(key);␍␊ |
␍␊ |
␉}␍␊ |
}␍␊ |
␍␊ |
variant ptdecl get(tparray & t, const variant & val)␍␊ |
{␍␊ |
␉for(int i = 0; i < t._keys.get_count(); i++)␍␊ |
␉//for(int i = 0; i < t._keys.size(); i++)␍␊ |
␉//for(int i = 0; i < t._keys.get_count(); i++)␍␊ |
␉for(int i = 0; i < alength(t._keys); i++)␍␊ |
␉{␍␊ |
␉␉if (t._keys[i] == val)␍␊ |
␉␉if (t._keys[(large)i] == val)␍␊ |
␉␉{␍␊ |
␉␉␉return t._vals[i];␍␊ |
␉␉␉return t._vals[(large)i];␍␊ |
␉␉}␍␊ |
␉}␍␊ |
␉return NULL;␍␊ |
}␍␊ |
␍␊ |
variant ptdecl at(tparray & t, int index)␍␊ |
variant ptdecl at(tparray & t, large index)␍␊ |
{␍␊ |
␉return t._vals[index];␍␊ |
}␍␊ |
␍␊ |
variant ptdecl keyat(tparray & t, int index)␍␊ |
variant ptdecl keyat(tparray & t, large index)␍␊ |
{␍␊ |
␉return t._keys[index];␍␊ |
}␍␊ |