How to I run multiple threads in VB.NET?
Say I need 2 threads - one that prints 100 numbers in a loop and the second one that asks for the user's name and prints it inside a message box.
I have the need to perform algorithms on various primitive types; the algorithm is essentially the same with the exception of which type the variables are. So for instance,
/**
* Determine if <code>value</code> is the bitwise OR of elements of <code>validValues</code> array.
* For instance, our valid choices are 0001, 0010, and 1000.
* We are given a value of 1001. This is valid because it can be made from
* ORing together 0001 and 1000.
* On the other hand, if we are given a value of 1111, this is invalid because
* you cannot turn on the second bit from left by ORing together those 3
* valid values.
*/
public static boolean isValid(long value, long[] validValues) {
for (long validOption : validValues) {
value &= ~validOption;
}
return value != 0;
}
public static boolean isValid(int value, int[] validValues) {
for (int validOption : validValues) {
value &= ~validOption;
}
return value != 0;
}
How can I avoid this repetition? I know there's no way to genericize primitive arrays, so my hands seem tied. I have instances of primitive arrays and not boxed arrays of say Number objects, so I do not want to go that route either.
I know there are a lot of questions about primitives with respect to arrays, autoboxing, etc., but I haven't seen it formulated in quite this way, and I haven't seen a decisive answer on how to interact with these arrays.
I suppose I could do something like:
public static<E extends Number> boolean isValid(E value, List<E> numbers) {
long theValue = value.longValue();
for (Number validOption : numbers) {
theValue &= ~validOption.longValue();
}
return theValue != 0;
}
and then
public static boolean isValid(long value, long[] validValues) {
return isValid(value, Arrays.asList(ArrayUtils.toObject(validValues)));
}
public static boolean isValid(int value, int[] validValues) {
return isValid(value, Arrays.asList(ArrayUtils.toObject(validValues)));
}
Is that really much better though? Any thoughts in this matter would be appreciated.
Hello All,
I am having tried a access 2007 report with fixed numbers of rows (records) per page. For example, I like to fix total number of records (rows) to 10 per page while underlying query might have 5 records in some criteria or 15 records in some case. If any idea, please share me.
TIA
ProNek
I'd like to get some help in the following exam problem, i have no idea how to do this:
Input: a list of numbers, eg.: [1,2,3,4]
Output: every possible correct bracketing. Eg.: (in case of input [1,2,3,4]):
((1 2) (3 4))
((1 (2 3)) 4)
(1 ((2 3) 4))
(1 (2 (3 4)))
(((1 2) 3) 4)
Bracketing here is like a method with two arguments, for example multiplication - then the output is the possible multiplication orders.
Please help, i'm stuck with this one. Any help is appreciated, thanks!
Hi,
Can someone validate the following. I am supposed to
'write a formula asserting that for every number there's a unique next number...true for integers for instance'
L(x,y) means x is smaller than y
the intended Domain is the Integer numbers
Can I give
∀x ∀y [ x<y ⇒ ( ∃z : z<x ∨ y<z ) ]
Thanks
I have a vector of 358 numbers. I'd like to make a numerical integration of this vector, but I don't know the function of this one.
I found that we can use trapz or quad, but i don't really understand how to integrate without the function.
I'm having some trouble to do the following:
int[] tmpIntList = (int[])MyArrayList.toArray(someValue);
MyArrayList contains only numbers. I get a typecast error since ArrayList only returns Object[] but why isnt it possible to turn it into a int[] ?
the most darndest thing! the following code prints out 'llo' instead of the expected 'wo'. i get such surprising results for a few other numbers. what am i missing here?
alert('helloworld'.substring(5, 2));
Hiya.
I need to create a dynamic array in Java, but the values type differ from String to Int to float. how can I create a dynamic list that I don't need to give it in advanced the type of the values?
The keys just need to be ascending numbers (1,2,3,4 or 0,1,2,3,4)
I checked ArrayList but it seems that I have to give it a fixed type for the values.
thanks!
Is there a way (ideally easy) to make headings and sections autonumber in HTML/CSS? Perhaps a JS library?
Or is this something that is hard to do in HTML?
I'm looking at an application for a corporate wiki but we want to be able to use heading numbers like we always have in word processors.
Well i'm totaly lost here, i am using jquery ui sliderwidget to make this quite simple menu but i just can't figure out a basic formula to make menu items slide along with with scroll bar.
Here is jsfiddle: http://jsfiddle.net/n2H6Q/4/
Please keep in mind that content height can change to any value that's why i have use random height, and container height can as well change to any value, that's why it is so difficult for me to figure out how to deal with all these numbers...
Any kind of help would be very much appreciated.
I have a lot of constants in my code that are unsigned numbers, e.g. counters, frequency cutoffs, lengths, etc. I started using std::size_t for all of these, instead of int or unsigned int.
Is that the right thing to do? I started it because the STL containers use it for their sizes, it's used for string position, etc.
Hi There,
I have a field in my database that contain comma seperated values these values are numbers, and I am trying to do a search and count the number of times that a number appears in that column throughout the column,
$sql = "SELECT sector_id_csv, COUNT(sector_id_csv) as count FROM cv WHERE sector_id_csv LIKE '$sectorId'";
This seems slow and does not return any results, and I know the sector_id it is search exsists in the table.
just wondering
california's license plate is
0XXX0000
number, 3 alphabets and 4 numbers.
how many permutation / combinations of total different license plate it could be ? i learned this in discrete structure but I have forgotten
I have some strings that need a-strippin':
ÃœT: 9.996636,76.294363
Tons of long strings of location codes. A literal regex in PHP won't match them, IE
$pattern = /ÃœT:/;
echo preg_replace($pattern, "", $row['location']);
Won't match/strip anything. (To know it's working, /T:/ does strip the last bit of that string). What's the encoding error doing on here?
Alternately, I would accept a concise way to take out just the numbers.
I am currently working on an ASP.NET 3.5 and C# web application which deals with users secure information like credit card numbers. What are some of the security measures which I need to take from an application development stand point so that I can sleep peacefully at night :)
Hey im new to python. How do you get a portion of a list by the relative value of its sorting key.
example...
list = [11,12,13,14,15,16,1,2,3,4,5,6,7,8,9,10]
list.sort()
newList = list.split("all numbers that are over 13")
assert newList == [14,15,16]
say ive got a matrix that looks like:
[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
how can i make it on seperate lines:
[[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]]
and then remove commas etc:
0 0 0 0 0
And also to make it blank instead of 0's, so that numbers can be put in later, so in the end it will be like:
_ 1 2 _ 1 _ 1
(spaces not underscores)
thanks
Going to be getting a single PDF that has been created by 'merging' multiple pdf's. When I view the merged PDF each single PDF is displayed as a bookmark.
Is there any way to automatically split this up by bookmarks with a script?
We would not know the page numbers, so that's not an option.
I have some strings that need a-strippin':
ÃœT: 9.996636,76.294363
Tons of long strings of location codes. A literal regex in PHP won't match them, IE
$pattern = /ÃœT:/;
echo preg_replace($pattern, "", $row['location']);
Won't match/strip anything. (To know it's working, /T:/ does strip the last bit of that string). What's the encoding error going on here?
Alternately, I would accept a concise way to take out just the numbers.
The question gives all necessary data: what is an efficient algorithm to generate a sequence of K non-repeating integers within a given interval. The trivial algorithm (generating random numbers and, before adding them to the sequence, looking them up to see if they were already there) is very expensive if K is large and near enough to N.
The algorithm provided here seems more complicated than necessary, and requires some implementation. I've just found another algorithm that seems to do the job fine, as long as you know all the relevant parameters, in a single pass.
Now I get two collections: coll01 and coll02.
And the structure of coll01 is like this:
{
id: 01,
name: "xxx",
age: 30
}
and the structure of coll02 is like:
{
id: 01,
name: "XYZ"
gender: "male"
}
The two id fields in the both collection are indices. And the numbers of documents in these two collections are same.
And what I want to do in traditional SQL is :
update coll01, coll02
set coll01.name = coll02.name
where coll01.id = coll02.id
When I read a sheet into a DataTable using the OleDbDataReader, floating point numbers loose their precision.
I tried forcing OleDb to read the excel data as string, but although the data is now contained in a DataRow with each Column defined as System.String it looses precision (18.125 - 18.124962832).
Any idea how to avoid this behaviour?
Hi
OK I need to figure out how to count how many numbers are in the following example.
07000000000,07000000001,07000000002,07000000003,07000000004 etc...
I have tried the following PHP functions.
explode, implode, count, foreach and for.
None of them seemed to have worked and I am really stuck now.
Any help will is appriciated.
Kyle