Java-Gaming.org
Java4K winners:
[
by our judges
|
by the community
]
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members
News
: Read the
Java Gaming Resources
, or peek at
the official Java tutorials
Home
Help
Search
Login
Register
Java-Gaming.org
>
Game Development
>
Performance Tuning
>
Sequential Map
Pages: [
1
]
Print
Sequential Map
(Read 1397 times)
0 Members and 1 Guest are viewing this topic.
Sanxion
Jr. Member
Posts: 55
Java games rock!
Sequential Map
«
on:
2003-08-30 17:46:54
»
I need to:
1) retrieve values using keys
2) be able to iterate the contents in the order they were inserted.
I can't find this functionality in any of the Maps. Have I missed one or I must I make my own? If thats the case, how to make it speedy for get and iteration.
tom
JGO Neuromancer
Posts: 1113
Medals: 5
Re: Sequential Map
«
Reply #1 on:
2003-08-30 18:31:31
»
Don't believe there exist a Map that does exactly this. I would suggest you make your own class using a Hastable for 1) and a Vector for 2).
The other option would be to use a SortedMap where you use your own Comparable interface. But I guess you would have to bake in a insertion id in the key.
Undead Arena
kevglass
« League of Dukes »
JGO Kernel
Posts: 5214
Medals: 49
Mentally unstable, best avoided.
Re: Sequential Map
«
Reply #2 on:
2003-08-31 01:46:42
»
You could always wrap a list and a map into one object. It might save you worrying about implemenation and you could rely on the exiting collections for performance.
Kev
Current
|
Home
|
Twitter
|
Slick
|
Phys2D
|
Tutorials
Games published by our own members! Go get 'em!
Sanxion
Jr. Member
Posts: 55
Java games rock!
Re: Sequential Map
«
Reply #3 on:
2003-08-31 04:09:34
»
Would using two Arrays be a good idea?
String [] keys;
Object [] values;
I don't need to modify its contents beyond initialization of the program.
NVaidya
Jr. Member
Posts: 95
Java games rock!
Re: Sequential Map
«
Reply #4 on:
2003-08-31 04:14:50
»
If you haven't already examined it, check out
java.util.LinkedHashMap. I've found it very useful
on specific occassions.
Gravity Sucks !
Sanxion
Jr. Member
Posts: 55
Java games rock!
Re: Sequential Map
«
Reply #5 on:
2003-09-01 06:36:45
»
LinkedHashMap worked perfectly. I wonder if a I would gain anything by implementing my own thing based on Arrays? Isn't Arrays the most effiecient way to iterate objects?
troggan
Full Member
Posts: 113
no guts no glory
Re: Sequential Map
«
Reply #6 on:
2003-09-01 07:54:46
»
You could gain a little bit speed with implementing that. but i don't think it's worth the work
.
Never forget: write first, profile, fix all things that are too slow.
Don't try to optimize before profiling
.
troggan
(
http://www.wannawork.de
) - Will work for food
(
http://tvbrowser.org
) - Java EPG
Pages: [
1
]
Print
Jump to:
Please select a destination:
-----------------------------
Games Center
-----------------------------
=> Featured Games
=> Showcase
=> Contests
===> LWJGL16k - 2011
===> 4K Game Competition - 2012
===> JGO Comp Petite
===> Finished Contests
=====> 4K Game Competition - 2011
=====> 4K Game Competition - 2010
=====> 4K Game Competition - 2009
=====> 4K Game Competition - 2008
=====> 4K Game Competition - 2007
=====> 4K Game Competition - 2006
=====> 4K Game Competition - 2005
=====> Tiny Game 2010
=====> JGO Comp 2009
=====> 16K LWJGL Competition - 2005
=====> Java Technology Game Development Contest - 2004
-----------------------------
Discussions
-----------------------------
=> General Discussions
===> Suggestions
=> Business and Project Discussions
===> Jobs and Resumes
===> Community & Volunteer Projects
=> Miscellaneous Topics
-----------------------------
Game Development
-----------------------------
=> Newbie & Debugging Questions
=> Articles & tutorials
=> Game Play & Game Design
=> Game Mechanics
===> Artificial Intelligence
=> Networking & Multiplayer
=> Performance Tuning
=> Shared Code
-----------------------------
Java Game APIs & Engines
-----------------------------
=> Engines, Libraries and Tools
===> Java 3D
===> JInput
===> jMonkeyEngine
===> Xith3D Forums
===> Tools Discussion
=> Java 2D
===> JavaFX
=> OpenGL Development
===> JOGL Development
===> LWJGL Development
=> Java Sound & OpenAL
===> JOAL Development
=> Java on Mobile Devices
===> Android
===> J2ME
Loading...