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, ...}; 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?
...
}
一件垃圾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?
...
}
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 =...
|
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...
|
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...
|
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;
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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://" +...
|
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...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |