magikker / TreeHouse-Private

TreeHouse development.
GNU General Public License v3.0
0 stars 0 forks source link

PQLSymbol should support a vector of treesets #23

Closed magikker closed 11 years ago

magikker commented 11 years ago

OK, so take a look at the pqlsymbol class. It's not the prettiest. but what it does is allow us to pass around generic things.

it's got two variables that you want to look at

vector<pqlsymbol * > list; std::set treeset;

The first one let's it hold a vector of anything else... that's the recursive part of the pqlsymbol. it can hold vectors of vectors of vectors of ints if you want. Just by nesting symbols in symbols.

The second one is what let's it hold a treeset. So, as far as PQLsymbol is concerned it can hold a vector of treesets. The problem is copying them (which happens as part of passing them around) retrieving values, and maybe printing.

But I'm noticing in the code that some parts of the pqlsymbol code aren't really updated to handle vectors of treesets.

for instance get_value_as_new_pqlsymbol() doesn't really handle nested vectors or vectors of treesets.

we probably will also need a get_treeset_vect() function.

To get it to work, I'd probably start by making treeset a data_type instead of object type. Then consider treesets to be atom/treeset.... which isn't the best logically but ought to work. Then handle it in get_value_as_new_pqlsymbol() for a when a otype is list and dtype is treeset.... as that'd be your vector of treesets.

Then we'd need to make sure the treeset version of the constructor is changed to treat a tree set as an ATOM, TREESET.

That, fingers crossed should be about it.

jaHoltz commented 11 years ago

Does this now. Vector of treesets supported.

Unless something comes up broken to do with treesets I've made the changes suggested here and tested it on my silhouette function (currently the only thing accepting vectors < set < unsigned int > > I believe) and everything seems alright. I've also tested it on consensus and some others (which just takes a treeset), just in case changing TREESET from an otype to a dtype messed something up along the way. Seems to work fine on my end.

Process was mostly as suggested, a few changes had to be made because of the switching otype and dtype around, and a constructor had to be made just for vector <set < unsigned int > >, as well as adding a handler in get_value_as_new_pqlsymbol().

magikker commented 11 years ago

Very cool. Looking forward to testing this out. Awesome.