I have a set of objects in a Vector from which I'd like to select a random subset (e.g. 100 items coming back; pick 5 randomly). In my first (very hasty) ... |
We all know you can't do this:
for (Object i : l)
if (condition(i)) l.remove(i);
ConcurrentModificationException etc... this apparently works sometimes, but not always. Here's some specific code:
public static void ...
|
This question is a more special case of the problem described (and solved) in this question.
I have two methods, stopAndRemove(ServerObject server) and a close() method. The later should close all ... |
I have problem reading/println after the first two FOR loop in this method.
This is strange. How can I solve this problem?
private int spacing() {
int n = numberOfTriangles();
...
|
We have a part of an application where, say, 20% of the time it needs to read in a huge amount of data that exceeds memory limits. While we can ... |
I'm trying to implement an algorithm that repeatedly applies operations on a Collection (currently a List). In each step Elements can be added, removed and changed (using getters and setters) within ... |
Imagine you have a set of five elements (A-E) with some numeric values of a measured property (several observations for each element):
A = {100, 110, 120, 130}
B = {110, 100, 110, ...
|
|
there is a poker-system in java, that uses Collections.shuffle() on all available cards before the cards are dealt.
So a collection of 52 cards 2-9, J, Q, K, A in 4 types.
After ... |
I have a collection of strings that I want to filter. They'll be in this pattern:
xxx_xxx_xxx_xxx
so always a sequence of letters or numbers separated by three underscores. The max length of ... |
I have a list of more than 37K items, and I already implemented hashCode(), equals(), so I wonder Collections.binarySearch() can help improve the performance and faster than indexOf() method.
|
I am brushing up algorithms and data structures and have a few questions as well as statements I would like you to check.
ArrayList - O(1) (size, get, set, ...), O(n) - ... |
Say you have a List of Strings or whatever, and you want to produce another List which will contain every possible combination of two strings from the original list (concated together), ... |
I have a collection of sets with numbers in it. Say
A = {-2, 5, 6, 8}
B = {-2, 4}
C = {-2, 4, 6, 8} ...
|
|
|