473,473 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to Find Array Names in a Set

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, ...};
Jun 27 '08 #1
2 2791
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.
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" <te********@comcast.netwrote in message
news:fI******************************@comcast.com. ..
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?
...
}

Jun 27 '08 #2
一件垃圾QQ:361975335, 代*骗*

http://forum2.kingofcoders.com/viewt...%3D1&frombbs=1


Jazz Kyat 提到:
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?
...
}

Oct 3 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: James | last post by:
Hi, Have posted before, but will simplify problem here. For original post go to http://forums.devshed.com/t80025/s.html I have setup 2 arrays like so in my one page script: $carers =...
47
by: VK | last post by:
Or why I just did myArray = "Computers" but myArray.length is showing 0. What a hey? There is a new trend to treat arrays and hashes as they were some variations of the same thing. But they...
8
by: J. B. Moreno | last post by:
What's the best (i.e. fastest) way to find out if an array contains a given value? Other than looping, the only way I know to do it is to use an associative array/hash instead.... Is there a...
19
by: gaga | last post by:
I can't seem to get this to work: #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char *names; char **np;
10
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a...
4
by: bienwell | last post by:
Hi all, Data displayed on the datalist control is bound by the column name of the dataset like this : <%# DataBinder.Eval(Container.DataItem, "title")%> Could I use an element of the array...
5
by: John Brock | last post by:
I am using VB.NET to read Excel workbooks which have various named ranges, some of which may not exist in any given workbook. I am trying to get a list of all the range names -- otherwise I need...
2
by: JJA | last post by:
I'm looking at some code I do not understand: var icons = new Array(); icons = new GIcon(); icons.image = "somefilename.png"; I read this as an array of icons is being built. An element of...
11
by: Piotrek | last post by:
Hi, I have no idea why my reallocation function (myadd) is breaking up my array. I'm trying to solve it and it took me few hours already. Maybe you can look at my code and explain me what is...
5
by: Pukeko | last post by:
Hi, this is an array that is used for a dropdown menu. var imageArray = new Array( "ecwp://" + document.location.host + "/massey/images/massey/ massey_07_fullres.ecw", "ecwp://" +...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.