Hi Ripston,

the virtual list can only work with an array of qx objects. So your transfer
efficient data structure wouldn't work with the current list implementation.
But I think there is no real runtime issue, because independent from the
data structure you have to create one qx object for each list item.

An algorithm for your data structure have to iterate over all groups and
persons O(g+p) to create the needed objects. So only when the numbers of
groups and persons are nearly equals. The algorithm would be inefficient,
but for this case also the data structure would inefficient.

The algorithm for a tuple based data structure would iterate over all
persons O(p). But generally the numbers of groups would be much smaller and
using your data structure would be better.

I would implement an own algorithm to create the needed qx objects and would
not use the qx.data.marshal.Json or something similar. 

Just define a qx object with the needed properties (name, status, group,
etc.) and iterate over the raw data. I think this is a good trade-off.

Now to the update issue. Due the array restriction from the virtual list
there is no efficient algorithm to update the state. An idea to avoid the
expensive search is to create something like an lookup table (a map with the
unique name as key and the reference to the object as value).

Here a pseudocode example:
var model = new qx.data.Array();
var lookup = {};
for (var i = 0; i < roster.length; i++)
{
  var group = roster[i];
  for (var k = 0; k < group.members.length; k++)
  {
    var member = group.members[k];
    var item = new my.Class(member.name, member.status, member.group);
    model.push(item);
    lookup[item.name] = item;
  }
}

Cheers,
Chris



--
View this message in context: 
http://qooxdoo.678.n2.nabble.com/Creating-grouped-list-from-group-structured-JSON-data-tp7583449p7583470.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to