FW: [Seaside] [Q] Best data structure for...

smalltalk at jgfoster.net smalltalk at jgfoster.net
Mon Nov 26 15:50:33 UTC 2007


If you are using GLASS (http://seaside.gemstone.com), you add your data to
an UnorderedCollection (typically an IdentitySet) and then ask it to keep
things indexed for you. 

	myCollectionOfData 
		createEqualityIndexOn: title        withLastElementClass:
String;
		createEqualityIndexOn: creationDate withLastElementClass:
Date  ;
		createEqualityIndexOn: modifiedDate withLastElementClass:
Date  ;
		createEqualityIndexOn: type         withLastElementClass:
Symbol;
		yourself.

>From then on the indexes are automatically updated based on adds and
removes. Queries use a special "select block" syntax:

	recentDate := Date today subtractDays: 10.
	recentlyModified := myCollectionOfData select: {:each |
each.modifiedDate >= recentDate}.

James

On Nov 25, 2007 10:22 PM,  <chunsj at embian.com> wrote:
> Hi,
>
> my data class has following attributes;
>
> title
> content
> creation date
> modified date
> type
>
> and except content, the collection of
> elements of this data shlould be indexed; that is,
> title, creation/modified date and type be key.
>
> If single key is required, then dictionary will be my choice(or
> should I use tree?). What is the best data structure for multiple
> keyed data? This question has been one of my hurddle to the
> OODB; if like now, sql db will be used, I know how to handle this.
>
> Thanks in advance.



More information about the seaside mailing list