Aggregating sublists

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Aggregating sublists

Efuehrer
Folks,

I have searched the forum, but haven't been successful so far.
What i am looking for is a way to create a list of items that have their quantities derived from other lists.
For example:
I have a list in module a with
Item a (quantity 3)
Item b (quantity 1)

And a list in module b with
Item a (quantity 2)
Item c (quantity 1)

In a list one higher in the hierarchy i want to create a list from the lists above as follows:
Item a (quantity 5)
Item b (quantity 1)
Item c (quantity 1)

So i don't want to change the type of elements in the upper list, just the quantities by aggregating the sublists. I checked the API but i couldn't find an apparent candidate where to start from. Did you cross that problem in the past?

Thanks in advance,
Erich
Reply | Threaded
Open this post in threaded view
|

Re: Aggregating sublists

James Lemieux
Hi Erich,

   So, the most straightforward way to accomplish this is chaining 3 different transforms together:

So, assuming you start with:

Source EventList A containing {a3, b1}
Source EventList B containing {a2, c1}

You'll want to merge them into a single EventList using CompositeList. (note that A and B must share a common lock and publisher to do this)

So, you'll have CompositeList C containing {a3, b1, a2, c1}

Now you'll want group elements by their character using GroupingList:

So, you'll have GroupingList D containing {{a3, a2}, {b1}, {c1}}

And finally, you can use FunctionList to map each element in D to a new corresponding object of your own design.

So, you'll have a readonly FunctionList E containing {a5, b1, c1}

Where the function you supply simply sums the count of all elements in the group.

I realize this is quite a bit of work to accomplish your goal, but I can't think of a simpler way.

James

On Fri, Dec 28, 2012 at 12:14 PM, Efuehrer <[hidden email]> wrote:
Folks,

I have searched the forum, but haven't been successful so far.
What i am looking for is a way to create a list of items that have their
quantities derived from other lists.
For example:
I have a list in module a with
Item a (quantity 3)
Item b (quantity 1)

And a list in module b with
Item a (quantity 2)
Item c (quantity 1)

In a list one higher in the hierarchy i want to create a list from the lists
above as follows:
Item a (quantity 5)
Item b (quantity 1)
Item c (quantity 1)

So i don't want to change the type of elements in the upper list, just the
quantities by aggregating the sublists. I checked the API but i couldn't
find an apparent candidate where to start from. Did you cross that problem
in the past?

Thanks in advance,
Erich



--
View this message in context: http://glazedlists.1045722.n5.nabble.com/Aggregating-sublists-tp5709812.html
Sent from the GlazedLists - User mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

AW: Aggregating sublists

Efuehrer

Ah…

Thanks for pointing out the obvious to me, it’s not always easy to see the forest with all of those trees in there…

 

I was already looking at GroupingList, but couldn’t bring my mind to treat an EventList as an object legible to transform with a FunctionList. I will definitely give it a try.

 

Thanks for the tip!

 

Erich

 

Von: James Lemieux [via GlazedLists] [mailto:[hidden email]]
Gesendet: Freitag, 28. Dezember 2012 22:21
An: Efuehrer
Betreff: Re: Aggregating sublists

 

Hi Erich,

 

   So, the most straightforward way to accomplish this is chaining 3 different transforms together:

 

So, assuming you start with:

 

Source EventList A containing {a3, b1}

Source EventList B containing {a2, c1}

 

You'll want to merge them into a single EventList using CompositeList. (note that A and B must share a common lock and publisher to do this)

 

So, you'll have CompositeList C containing {a3, b1, a2, c1}

 

Now you'll want group elements by their character using GroupingList:

 

So, you'll have GroupingList D containing {{a3, a2}, {b1}, {c1}}

 

And finally, you can use FunctionList to map each element in D to a new corresponding object of your own design.

 

So, you'll have a readonly FunctionList E containing {a5, b1, c1}

 

Where the function you supply simply sums the count of all elements in the group.

 

I realize this is quite a bit of work to accomplish your goal, but I can't think of a simpler way.

 

James

 

On Fri, Dec 28, 2012 at 12:14 PM, Efuehrer <[hidden email]> wrote:

Folks,

I have searched the forum, but haven't been successful so far.
What i am looking for is a way to create a list of items that have their
quantities derived from other lists.
For example:
I have a list in module a with
Item a (quantity 3)
Item b (quantity 1)

And a list in module b with
Item a (quantity 2)
Item c (quantity 1)

In a list one higher in the hierarchy i want to create a list from the lists
above as follows:
Item a (quantity 5)
Item b (quantity 1)
Item c (quantity 1)

So i don't want to change the type of elements in the upper list, just the
quantities by aggregating the sublists. I checked the API but i couldn't
find an apparent candidate where to start from. Did you cross that problem
in the past?

Thanks in advance,
Erich



--
View this message in context: http://glazedlists.1045722.n5.nabble.com/Aggregating-sublists-tp5709812.html
Sent from the GlazedLists - User mailing list archive at Nabble.com.

 

 


If you reply to this email, your message will be added to the discussion below:

http://glazedlists.1045722.n5.nabble.com/Aggregating-sublists-tp5709812p5709813.html

To unsubscribe from Aggregating sublists, click here.
NAML