I'm not sure if I understand your question correctly, but I think you want
to use a HashMap, not a HashSet.
A HashMap allows you to identify the content by something else, such as a
name.
Quote:
double array1 = {1.0, 2.0, 3.0, ...};
double array2 = {1.0, 2.0, 3.0, ...};
double array3 = {1.0, 2.0, 3.0, ...};
>
Set<String, double[] hs = new HashMap<String, double[]>();
hs.put("array1", array1);
hs.put("array2", array2);
hs.put("array3", array3);
.
// Retrieve name of array, say arrayX, from a text field.
>
// ArrayX will not be found because arrayX is a String and Array1, etc,
are array objects.
if (hs.contains("array1")) { // How do I test for arrayX?
double [] some_array = hs.get("array1");
}
"Jazz Kyat" <technewsie@comcast.netwrote in message
news:fISdnS_Zb7KojKbVnZ2dnUVZ_u-dnZ2d@comcast.com...
Quote:
Hello,
>
I have a series of arrays that I inserted into a HashSet. Now I want to
find out whether a particular array is contained in the set; how do I do
that? Here is what the code looks like:
>
double array1 = {1.0, 2.0, 3.0, ...};
double array2 = {1.0, 2.0, 3.0, ...};
double array3 = {1.0, 2.0, 3.0, ...};
.
.
.
>
Set<double[] hs = new HashSet<double[]>();
hs.add(array1);
hs.add(array2);
hs.add(array3);
.
.
.
>
// Retrieve name of array, say arrayX, from a text field.
>
// ArrayX will not be found because arrayX is a String and Array1, etc,
are array objects.
if (hs.contains(arrayX)) { // How do I test for arrayX?
...
}
>
>