Jeremy in your StaticSet.java you use ArrayList and Iterator. Neither of these are available to me whereas the NoSuchElement is.
Could I possibly use my own ArrayList as a substitute for the ArrayList<>. However the iterator part i@m not too sure on.
Yeah, they’ve left out some classes that make things easier. I’ll use the unsortedreadablelist. Does sorting matter? and I’ll also check the enumeration for the for each, can i not simply use a basic for loop for this?
Scratch my solution. You need a sorted list to store the mutations (they need to be applied in the proper order.)
Sorry for wasting your time.
That BB JDE seems terribad. Last I checked, BlackBerry (canadian company) was doing terribly and is thinking of selling to an Chinese organization.
The simplest solution for this (psuedo code)
ArrayList garbage;
for(item i : myList)
{
if(someCondition)
garbage.add(i);
}
myList.removeAll(garbage);
But it isn’t very memory efficient. You could reuse your garbage arraylist which would help a lot. Ofcourse, you might run into the problem I’ve stated above (in my first post in this thread)
I think it might, if i can create a way to clone it then i could possibly clone the arraylist to another arraylist, remove the object from the temporary arraylist and then at the end set the permanent one the same as the tmp one?
Yeah, cloning should work fine. Just make sure you only do a shallow clone. The only problem with this approach (and if it isn’t a problem for you - and it probably isn’t) is that you end up creating a lot of shallow clones. Just be clever about when you clone and it shouldn’t be a problem.
Yeah, for the cloning I’m thinking of two solutions to it.
To clone it everytime i remove an element, or to create another array with each of the positions of the objects to be removed, then clone the arraylist, iterate through the array with the positions, then remove the objects from the temporary one, and then set the original list the same as the temp one.
Multiple rockets will fire, but if i move the ship, therefore moving the starting x position of the rocket im getting the array out of bounds exception. Here is my porjectile, player rocket, array list, and methods that i use that when firing a rocket.
// Add the object to the array
public void add(PlayerRocket e)
{
if(getSize() >= DEFAULT_CAPACITY)
{
// Do nothing can't have more than 16 on screen at once
}
else
{
// add the object at specific point
elements[size++] = e;
}
}
If i try and reuse the rockets, everything is good, up until i get a different error. TooManyThreads. How exactly did i manage to get this o.O? How do I go about approaching it? I google it and it doesnt help me much, just some people posting on forums asking how many threads is too many