[Glass] Collection for reduced conflicts, allow indexes and #sort: ?

Dale K. Henrichs dale.henrichs at gemtalksystems.com
Thu Dec 5 14:36:10 PST 2013


----- Original Message -----

| From: "Mariano Martinez Peck" <marianopeck at gmail.com>
| To: glass at lists.gemtalksystems.com
| Sent: Thursday, December 5, 2013 8:06:08 AM
| Subject: [Glass] Collection for reduced conflicts, allow indexes and
| #sort: ?

| Hi guys. So...at some point in my app, I have a collection in which I
| store instances of a persistent class. Imagine class Client, so at
| some point I have a persistent collection of clients.

| Now... I want:

| 1) Reduced conflict collections
| 2) Be able to use indexes if I happen to need them later on (as far
| as I read it needs to be an unordered collection)
correct 

| 3) Be able to sort the collection given a closure
You can use #sorted: (has the advantage of being defined in Grease so it is "common" between GemStone and Pharo) which takes a standard sort block. If you have an indexed collection, you cannot use an arbitrary block to take advantage of the index ... you have to define a query against the collection ... 

| Just taking into account 1) and 2) it seems the only option is
| RcIdentityBag. Problem is that I cannot sort such collection with a
| simple #sort: aBlockClosure. I saw I have #sortWith:, #sortAsending:
| etc, but that's not what I need. I need to receive a block closure.

| I can send #asSortedCollection: aClosure to the RcIdentityBag but
| that answers an instance of a SortedCollection, not a RcIdentityBag
| sorted, which is different.

Bags, by definition are not ordered, so to get a sorted result you will end up with some sort of SequenceableCollection as a result, by necessity ... 

Dale 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20131205/aaa25862/attachment.html>


More information about the Glass mailing list