|
Re: Modeling a HashMap [message #425419 is a reply to message #425404] |
Tue, 25 November 2008 21:52 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------050707030306020301070800
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Derek,
Comments below.
Derek Palma wrote:
> Hi,
>
> I am trying to determine the appropriate pattern for modeling Maps
> with EMF. I basically need a Java-like HashMap kind of structure which
> can be a field of an EClass (realling nothing fancy, just String keys
> and values).
>
> What is the best way to model a map? In the EMF book the UML chapter
> talks about modeling maps with references to MapEntry classes.
> However, it seems I still have to handle the lookup myself.
No, EMaps should do the trick: 2.29 How do I create a Map in EMF?
< http://wiki.eclipse.org/index.php/EMF/FAQ#How_do_I_create_a_ Map_in_EMF.3F>
> I am presuming others have hit this before and there is a best
> practice approach for this. Can someone point me to some sample
> models/code for this?
>
> Thanks in advance.
> Derek
--------------050707030306020301070800
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Derek,<br>
<br>
Comments below.<br>
<br>
Derek Palma wrote:
<blockquote cite="mid:ggfjhl$6k6$1@build.eclipse.org" type="cite">Hi,
<br>
<br>
I am trying to determine the appropriate pattern for modeling Maps with
EMF. I basically need a Java-like HashMap kind of structure which can
be a field of an EClass (realling nothing fancy, just String keys and
values).
<br>
<br>
What is the best way to model a map? In the EMF book the UML chapter
talks about modeling maps with references to MapEntry classes. However,
it seems I still have to handle the lookup myself. </blockquote>
No, EMaps should do the trick: <a
href=" http://wiki.eclipse.org/index.php/EMF/FAQ#How_do_I_create_a_ Map_in_EMF.3F"><span
class="tocnumber">2.29</span> <span class="toctext">How do I create a
Map in EMF?</span></a>
<blockquote cite="mid:ggfjhl$6k6$1@build.eclipse.org" type="cite">I am
presuming others have hit this before and there is a best practice
approach for this. Can someone point me to some sample models/code for
this?
<br>
<br>
Thanks in advance.
<br>
Derek <br>
</blockquote>
</body>
</html>
--------------050707030306020301070800--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: Modeling a HashMap [message #1079856 is a reply to message #1079625] |
Mon, 05 August 2013 06:57 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Edward,
That way is okay. You could also sort in place with
org.eclipse.emf.common.util.ECollections.sort(EList<T>, Comparator<?
super T>) using a comparator that takes the Map.Entry values to induce a
sort order based on the key/value features of the map entry...
On 05/08/2013 12:16 AM, Edward MacKerrow wrote:
> Is there a clean way to sort EMaps by value ? Currently I am creating
> a TreeMap outside of EMF, creating a Comparator for the values in the
> TreeMap. Then, after I am done populating the TreeMap, creating an
> empty EMap and populating it from the sorted by value TreeMap. There
> is probably a better way to do this directly in EMF ?
> Thanks !
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04273 seconds