Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #28279
| Date | 2014-04-28 00:30 +0200 |
|---|---|
| From | Marcel Müller <news.5.maazl@spamgourmet.org> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: hash map / collection choice |
| References | <ljjnh1$852$1@online.de> |
| Message-ID | <535d8506$0$6707$9b4e6d93@newsspool2.arcor-online.net> (permalink) |
| Organization | Arcor |
On 27.04.14 21.58, Philipp Kraus wrote: > The edge ID is always unique. So I would like to create a collection in > which I can do something like > > myEdge x = edgecollection.get( searching edge id ) > > So the collection stores the edge objects and I can get an object with > the internal id. The collection > should use the the edgeid value to identify the object. > > A set should be the correct structure, but I can not get the object > itself of the map without iteration over all > items. A HashMap needs a key, value pair, so I need also a key class > which stores the edge id (redundant data). This is a well known limitation of the Java collections. They cannot deal with objects that have an embedded key. There are some good reasons for this restriction. I.e. if you modify the embedded key of an object in a container the entire container may get inconsistent. > I'm a little bit uncertain, which collection is the correct choice. You need a key value collection rather than a set. You can't come around the redundant keys because of the above restriction. Marcel
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
hash map / collection choice Philipp Kraus <philipp.kraus@flashpixx.de> - 2014-04-27 21:58 +0200
Re: hash map / collection choice leif.roar@invalid.com (Leif Roar Moldskred) - 2014-04-27 15:51 -0500
Re: hash map / collection choice Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-04-27 17:33 -0400
Re: hash map / collection choice leif.roar@invalid.com (Leif Roar Moldskred) - 2014-04-27 20:58 -0500
Re: hash map / collection choice Jeff Higgins <jeff@invalid.invalid> - 2014-04-27 22:04 -0400
Re: hash map / collection choice Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-04-27 17:05 -0400
Re: hash map / collection choice Jeff Higgins <jeff@invalid.invalid> - 2014-04-27 17:52 -0400
Re: hash map / collection choice Philipp Kraus <philipp.kraus@flashpixx.de> - 2014-04-28 07:38 +0200
Re: hash map / collection choice leif.roar@invalid.com (Leif Roar Moldskred) - 2014-04-28 01:13 -0500
Re: hash map / collection choice Philipp Kraus <philipp.kraus@flashpixx.de> - 2014-04-28 22:20 +0200
Re: hash map / collection choice Joerg Meier <joergmmeier@arcor.de> - 2014-04-28 23:26 +0200
Re: hash map / collection choice Arne Vajhøj <arne@vajhoej.dk> - 2014-04-28 18:41 -0400
Re: hash map / collection choice Joerg Meier <joergmmeier@arcor.de> - 2014-04-29 10:48 +0200
Re: hash map / collection choice Arne Vajhøj <arne@vajhoej.dk> - 2014-04-29 17:40 -0400
Re: hash map / collection choice Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-04-28 08:03 -0400
Re: hash map / collection choice Marcel Müller <news.5.maazl@spamgourmet.org> - 2014-04-28 00:30 +0200
Re: hash map / collection choice markspace <markspace@nospam.nospam> - 2014-04-27 16:37 -0700
Re: hash map / collection choice Roedy Green <see_website@mindprod.com.invalid> - 2014-04-27 16:49 -0700
csiph-web