Implementation issue.
Set is based on dictionary and thus a waste of memory. We want low memory footprint and fast access (adding is only down when loading a model). Array is the best solution, occasionally adding element with copyWith:. But we should make sure that no duplicates are added, and raise error if someone tries so! I guess that test is missing.
AA
On 22 Nov 2007, at 15:28 , stephane ducasse wrote:
or an OrderedSet?
Stef _______________________________________________ Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
I thought so. Now would it be not better to add UniqueOrderedCollection so that this is in the contract of the class to only add element if it is not there and to waste less space than a set?
In that case can you edit the class comment and mention that they are unique collection?
Something related I would like to have a flatCollect with which I do not have to do asSet at the end. So a kind of flatUniqueCollect that still return an UniqueOrderedCollection instead of a set
Does it make sense to implement and use UniqueOrderedCollection or UniqueArray?
Implementation issue.
Set is based on dictionary and thus a waste of memory. We want low memory footprint and fast access (adding is only down when loading a model). Array is the best solution, occasionally adding element with copyWith:. But we should make sure that no duplicates are added, and raise error if someone tries so! I guess that test is missing.
AA
On 22 Nov 2007, at 15:28 , stephane ducasse wrote:
or an OrderedSet?
Stef _______________________________________________ Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Good idea. I'll write one right now.
AA loves writing custom collections :)
On 22 Nov 2007, at 21:32 , Stéphane Ducasse wrote:
I thought so. Now would it be not better to add UniqueOrderedCollection so that this is in the contract of the class to only add element if it is not there and to waste less space than a set?
In that case can you edit the class comment and mention that they are unique collection?
Something related I would like to have a flatCollect with which I do not have to do asSet at the end. So a kind of flatUniqueCollect that still return an UniqueOrderedCollection instead of a set
Does it make sense to implement and use UniqueOrderedCollection or UniqueArray?
Implementation issue.
Set is based on dictionary and thus a waste of memory. We want low memory footprint and fast access (adding is only down when loading a model). Array is the best solution, occasionally adding element with copyWith:. But we should make sure that no duplicates are added, and raise error if someone tries so! I guess that test is missing.
AA
On 22 Nov 2007, at 15:28 , stephane ducasse wrote:
or an OrderedSet?
Stef _______________________________________________ Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
There is #collectAsSet:
Is that what you ar looking for?
AA
On 22 Nov 2007, at 21:32 , Stéphane Ducasse wrote:
Something related I would like to have a flatCollect with which I do not have to do asSet at the end. So a kind of flatUniqueCollect that still return an UniqueOrderedCollection instead of a set
#collectAsSet: just returns the set of the collect, while Stef would want a #collectUnionAsSet: . But, if you do the UniqueOrderedCollection :), it should work, no?
Doru
On Nov 22, 2007, at 10:42 PM, Adrian Kuhn wrote:
There is #collectAsSet:
Is that what you ar looking for?
AA
On 22 Nov 2007, at 21:32 , Stéphane Ducasse wrote:
Something related I would like to have a flatCollect with which I do not have to do asSet at the end. So a kind of flatUniqueCollect that still return an UniqueOrderedCollection instead of a set
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com www.tudorgirba.com/blog
"Problem solving efficiency grows with the abstractness level of problem understanding."
#collectAsSet: just returns the set of the collect, while Stef would want a #collectUnionAsSet: . But, if you do the UniqueOrderedCollection :), it should work, no?
I want that flatcollect is by construction creating a unique result of the collect and not flattening it after the fact.
Stef
Doru
On Nov 22, 2007, at 10:42 PM, Adrian Kuhn wrote:
There is #collectAsSet:
Is that what you ar looking for?
AA
On 22 Nov 2007, at 21:32 , Stéphane Ducasse wrote:
Something related I would like to have a flatCollect with which I do not have to do asSet at the end. So a kind of flatUniqueCollect that still return an UniqueOrderedCollection instead of a set
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com www.tudorgirba.com/blog
"Problem solving efficiency grows with the abstractness level of problem understanding."
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Please have a look at
CodeFooDevelopment >> CodeFoo >> Collection >> enumerating
There is
#collectUnion: #flattern #gather: #recurisveCollect:
that all use a collection of the same species as the receiver, and
#collectAsSet: #transitiveClosure:
that use a Set for any collection. If your need is not covered by that, please feel free to add your own enumerators there.
cheers, AA
On 23 Nov 2007, at 9:00 , Stéphane Ducasse wrote:
#collectAsSet: just returns the set of the collect, while Stef would want a #collectUnionAsSet: . But, if you do the UniqueOrderedCollection :), it should work, no?
I want that flatcollect is by construction creating a unique result of the collect and not flattening it after the fact.
Stef
Doru
On Nov 22, 2007, at 10:42 PM, Adrian Kuhn wrote:
There is #collectAsSet:
Is that what you ar looking for?
AA
On 22 Nov 2007, at 21:32 , Stéphane Ducasse wrote:
Something related I would like to have a flatCollect with which I do not have to do asSet at the end. So a kind of flatUniqueCollect that still return an UniqueOrderedCollection instead of a set
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com www.tudorgirba.com/blog
"Problem solving efficiency grows with the abstractness level of problem understanding."
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Ok
I saw them before asking ans the use of species was good expect that I missed collectAsSet ;) Now I see it Stef
On 23 nov. 07, at 15:41, Adrian Kuhn wrote:
Please have a look at
CodeFooDevelopment >> CodeFoo >> Collection >> enumerating
There is
#collectUnion: #flattern #gather: #recurisveCollect:
that all use a collection of the same species as the receiver, and
#collectAsSet: #transitiveClosure:
that use a Set for any collection. If your need is not covered by that, please feel free to add your own enumerators there.
cheers, AA
On 23 Nov 2007, at 9:00 , Stéphane Ducasse wrote:
#collectAsSet: just returns the set of the collect, while Stef would want a #collectUnionAsSet: . But, if you do the UniqueOrderedCollection :), it should work, no?
I want that flatcollect is by construction creating a unique result of the collect and not flattening it after the fact.
Stef
Doru
On Nov 22, 2007, at 10:42 PM, Adrian Kuhn wrote:
There is #collectAsSet:
Is that what you ar looking for?
AA
On 22 Nov 2007, at 21:32 , Stéphane Ducasse wrote:
Something related I would like to have a flatCollect with which I do not have to do asSet at the end. So a kind of flatUniqueCollect that still return an UniqueOrderedCollection instead of a set
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com www.tudorgirba.com/blog
"Problem solving efficiency grows with the abstractness level of problem understanding."
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
SmartSet represents an unordered collection of elements that are not duplicated.
SmartSet can operate in two modes
- self optimizeGrowth, whereas its values are backed up by a conventional Set - self optimizeMemory, whereas its values are backed up by an Array
Other than Set, an attempt to add a duplicate element signals an Error.
AA
On 22 Nov 2007, at 21:32 , Stéphane Ducasse wrote:
Does it make sense to implement and use UniqueOrderedCollection or UniqueArray?
fun we should have also UniqueOrderedCollection (should be a couple of methods) BTW UniqueOrderedCollection could also have a fastAdd: (one that does not check uniqueness) if you need large collection and by contract the clients knows that it is responsible of not putting duplicated stuff in there.
Stef
On 22 nov. 07, at 23:46, Adrian Kuhn wrote:
SmartSet represents an unordered collection of elements that are not duplicated.
SmartSet can operate in two modes
- self optimizeGrowth, whereas its values are backed up by a
conventional Set
- self optimizeMemory, whereas its values are backed up by an Array
Other than Set, an attempt to add a duplicate element signals an Error.
AA
On 22 Nov 2007, at 21:32 , Stéphane Ducasse wrote:
Does it make sense to implement and use UniqueOrderedCollection or UniqueArray?
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
What is the difference between UniqueOrderedCollection and SmartSet (except for keyed access)?
I add #unsafeAdd: / #unsafeAddAll: / #assertInvariant to SmartSet.
cheers, AA
On 23 Nov 2007, at 9:02 , Stéphane Ducasse wrote:
fun we should have also UniqueOrderedCollection (should be a couple of methods) BTW UniqueOrderedCollection could also have a fastAdd: (one that does not check uniqueness) if you need large collection and by contract the clients knows that it is responsible of not putting duplicated stuff in there.
Stef
On 22 nov. 07, at 23:46, Adrian Kuhn wrote:
SmartSet represents an unordered collection of elements that are not duplicated.
SmartSet can operate in two modes
- self optimizeGrowth, whereas its values are backed up by a
conventional Set
- self optimizeMemory, whereas its values are backed up by an Array
Other than Set, an attempt to add a duplicate element signals an Error.
AA
On 22 Nov 2007, at 21:32 , Stéphane Ducasse wrote:
Does it make sense to implement and use UniqueOrderedCollection or UniqueArray?
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
for me SmartSet contract does not have to keep the order while UniqueOrderedCol has (at least the order of the first added occurrences of an item.
Stef
On 23 nov. 07, at 15:42, Adrian Kuhn wrote:
What is the difference between UniqueOrderedCollection and SmartSet (except for keyed access)?
I add #unsafeAdd: / #unsafeAddAll: / #assertInvariant to SmartSet.
cheers, AA
On 23 Nov 2007, at 9:02 , Stéphane Ducasse wrote:
fun we should have also UniqueOrderedCollection (should be a couple of methods) BTW UniqueOrderedCollection could also have a fastAdd: (one that does not check uniqueness) if you need large collection and by contract the clients knows that it is responsible of not putting duplicated stuff in there.
Stef
On 22 nov. 07, at 23:46, Adrian Kuhn wrote:
SmartSet represents an unordered collection of elements that are not duplicated.
SmartSet can operate in two modes
- self optimizeGrowth, whereas its values are backed up by a
conventional Set
- self optimizeMemory, whereas its values are backed up by an Array
Other than Set, an attempt to add a duplicate element signals an Error.
AA
On 22 Nov 2007, at 21:32 , Stéphane Ducasse wrote:
Does it make sense to implement and use UniqueOrderedCollection or UniqueArray?
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev