This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Which is going to return anywhere from 1 to 100 values on any given run. I was told on another forum for what Im needing to do I can use "either collections(list), array or maps." So which would be appropriate, or better yet, which will be easiest for me to use. DeviceCollection is just a list<devices> which holds a list of devices from the Device class, so keep in mind I need it to be compatible. So it might be best to just use the same data type that I am using in DeviceCollection
If I could just replace the ..... from that code with something like
byte [] = y;
y.append(x);
It would be preferred. Something that is simple. I will probably make a separate class to hold these values, so instead of y.append(x) I will use class.setValues(x); but the same question remains.
So I am very unfamiliar with collections in java, so what does someone experienced believe I should use here?
True wisdom is in knowing you know nothing - Socrates
Ernest Friedman-Hill
author and iconoclast
Marshal
So you have a method getDevices() that returns a collection of Device objects, and you want to do something to each Device, but I'm not sure what. Do you want to make a collection of the deviceId values? Is that it? If so, then pretty much any collection would work. What would narrow it down is what you want to do with the collection once you've made it. Do you envision iterating over the deviceIds in order? Then a List is good. Do you want a collection of unique deviceIds, with no duplicates? Maybe a Set would be better, then. Or do you want to quickly lookup a Device given its deviceId? In that case, a Map would fit the bill. Tell us what you want to actually achieve, and we'll help you figure out how to do it.
Well this object will change session to session, and depending on the user. The value this collection contains will be deviceid like you said, btu eventually there will be many others like project, name, channel, etc
These will be used in a richfaces tree to populate recursive tree nodes, so when a user logs in he will have a project explorer pane (similar to eclipse) that will have his projects as the roots, devices as a child of projects and channels as a child of devices.
-project
---device
------channel
A user can have multiple projects, a project can have multiple devices, adn a device can have multiple channels, so I need something to hold all the values for each which I can then bind to the tree nodnd
On the richfaces forum I was told that the data types I am able to bind to this recursive tree node are "collections(list), array or maps"
Oh and I do have a restriction on client response time (2ms if Im rememebring right), which is why I am asking this, because with my relative inexperience my code is already going to be clunky and sluggish as it is
Kavita Tipnis
Ranch Hand
Joined: Sep 21, 2008
Posts: 177
posted
0
Matt Kohanek wrote:Well this object will change session to session, and depending on the user. The value this collection contains will be deviceid like you said, btu eventually there will be many others like project, name, channel, etc
These will be used in a richfaces tree to populate recursive tree nodes, so when a user logs in he will have a project explorer pane (similar to eclipse) that will have his projects as the roots, devices as a child of projects and channels as a child of devices.
-project
---device
------channel
A user can have multiple projects, a project can have multiple devices, adn a device can have multiple channels, so I need something to hold all the values for each which I can then bind to the tree nodnd
On the richfaces forum I was told that the data types I am able to bind to this recursive tree node are "collections(list), array or maps"
Oh and I do have a restriction on client response time (2ms if Im rememebring right), which is why I am asking this, because with my relative inexperience my code is already going to be clunky and sluggish as it is
Matt, from what you described I am guessing my post at Last Post might help.
Root Nodes can refer to you projects in this case,
modify the RootNodes(Projects) to include List<Device>
modify Device to include List<Channel>
and for each user just iterate over this xmldata object.
Oh no, I had your post in mind when I made this thread. I definitely plan to make a separate class for this, but I just wanted to use the most optimal data type I could, since as I said the rest of my code is probably going to be slowing me down.
Kavita Tipnis
Ranch Hand
Joined: Sep 21, 2008
Posts: 177
posted
0
Matt Kohanek wrote:Oh no, I had your post in mind when I made this thread. I definitely plan to make a separate class for this, but I just wanted to use the most optimal data type I could, since as I said the rest of my code is probably going to be slowing me down.
I am not tasking you for not replying to my post ! Ok alternately, you can also use a Map<User,Project> to display the tree nodes
If you are talking in terms of efficiency of iterating through the collection,a brief look at the collections generics tutorial will help
Collections