Use of MagmaSet ?
Chris Muller
asqueaker at gmail.com
Fri Apr 6 02:02:34 UTC 2007
Hi Hilaire, there is an example of MagmaSet in the test cases. You
may like to check out MagmaTestCase>>#testMagmaSet in the MagmaTester
package.
But, looking at the code of MagmaSet, it is really very simple (just 7
methods). The crux of what it does is provide a guard; a check when
adding an object, whether an equivalentOf: thatObject is already
present. If it is.. signal an error?! That seems a bit harsh and
inconsistent with a regular Set, it should probably just ignore it.
But anyways..
equivalentOf: does the work of AND'ing all of your equivalence
attributes together into a single where: condition. This allows a
Reader of just a few objects to be scanned for an exact Smalltalk
equivalent (via #= and #hash implemented on your Learner object).
Adding to MagmaSets is very slow for this reason; each and every
object added causes a full query and enumeration of the result set.
But Brent had a need for them, so I put it in there..
Hope this helps..
- Chris
On 4/5/07, Hilaire Fernandes <hilaire2006 at laposte.net> wrote:
> I am using it that way, but something goes wrong as I can not find with
> index and duplication occure on the Set.
>
> Is it the correct way to initialize MagmaSet ? I did not find example of
> use.
>
> Hilaire
>
> learners := MagmaSet equivalenceAttributes: #(#id).
> learners
> addIndex: ((MaSearchStringIndex attribute: #firstName)
> keySize: 128);
> addIndex: ((MaSearchStringIndex attribute: #lastName)
> keySize: 128);
> addIndex: (MaIntegerIndex attribute: #id).
>
> _______________________________________________
> Magma mailing list
> Magma at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/magma
>
More information about the Magma
mailing list