//In header file: class definition:
class myString
{
public:
myString(void);
myString(const char *str);
myString(const myString &); //copy constructor
~myString(void); //destructor
void swap(myString &from);
private:
char *stringPtr;
int stringLen;
};
//in cpp file, defining them member fun...
I'm using VB.NET.
I am performing a select query that returns approximately 2500 rows, each containing 7 fields.
I am using a SqlDataAdapater and filling a dataset with the single table returned by the Select query (from the local database). (I only perform the data-retrieval once (see below) and I don't even start the StopWatch until...
I've got a sorted array:
array = [[4, 13], [1, 12], [3, 8], [2, 8], [0, 3]]
Which shows me a position (array[n][0]) and the number of occurrences of that position (array[n][1]).
I need to test to see if more than one item in the array has the same number of occurrences as the last item.
I thought I might be able to do it with this:
...
I just came across std::tr1::extent template and it puzzled me. I never ever dealt with array type parameters in my life so I don't understand how they work. So, given the code from gcc type_traits
template<typename _Tp, unsigned _Uint, std::size_t _Size>
struct extent<_Tp[_Size], _Uint>
template<typename _Tp, unsigned _Uint>
...
Hey there! I have a question about using Javacript to return search results from twitter. The idea is to use arrays, but we have not really covered them in class. Can anyone suggest how I might get started writing these functions?
Below is the template we are supposed to use:
/*
This function takes an array of "tweets" and conve...
What is the best way to take an array in VB.NET which can either be Nothing or initialised and give it a length of zero?
The three options I can think of are:
ReDim oBytes(-1)
oBytes = New Byte(-1) {}
oBytes = New Byte() {}
The first example is what most of the developers in my company (we used to do VB 6) have always used. I perso...
EDIT I checked the jQuery documentation and using $.ajax with the json datatype specified returns an evaluated javascript object, so eval() isn't the answer here. I knew that anyway, since I am able to parse single JSON objects, just not arrays. The problem is the $.each-ing my way through them :)
I have followed the syntax for parsin...
Thanks to the help in a previous question, I've got the following code returning the expected results with find_all.
Original array (sorted by votes[0]):
votes_array = [{"votes"=>[13], "id"=>"4", "elected"=>0}, {"votes"=>[12], "id"=>"1", "elected"=>0}, {"votes"=>[8], "id"=>"3", "elected"=>0}, {"votes"=>[3], "id"=>"2", "elected"=>0}, {...
I have two arrays of strings that I would like to compare for equality:
my @array1 = ("part1", "part2", "part3", "part4");
my @array2 = ("part1", "PART2", "part3", "part4");
Is there a built-in way to compare arrays like there is for scalars?
I tried:
if (@array1 == @array2) {...}
but it just evaluated each array in scalar context,...
How could I set a variable that I can read by using eval('productOptionTree' + '[0][1][0]')?
(the '[0][1][0]' part comes from another variable)
UPDATE
it's an ugly question, but I couldn't find another way to do it. the only answer I could find is:
newVal = 4;
dim = '[0][1][0]';
eval('productOptionTree'+dim+' = ' +newV...
Hello, I am a beginner programmer and I am attempting to use the android NDK.
Is there a way to return an array (in my case an int[]) created in JNI to java? If so, please provide a quick example of the JNI function that would do this.
-Thanks
...
I've two for loops that basically look up in two different arrays (each having a size around 2-4k at peak) and set a value in a 3rd array based on these values. For some weird reason there is a factor two difference between the performance of this piece of code depending on in which order I put the two for loops.
This is the first setup...
About two years ago I have found a component that can be used to create array with string keys on delphi... anyone know a component like this??
...
How can i pass an entire array to a method?
private void PassArray(){
String[] arrayw = new String[4];
//populate array
PrintA(arrayw[]);
}
private void PrintA(String[] a){
//do whatever with array here
}
how do i do this correctly?
...
In my class, I have a method that returns an array like this.
double arrValues[] = ClassX.getValues();
I wonder that, does the array size have any influence on performance. Are there any copy operation for arrValues[] or is it only a reference return ?
...
Imagine that I want to create an array from another array like this:
$array = array('bla' => $array2['bla'],
'bla2' => $array2['bla2'],
'foo' => $array2['foo'],
'Alternative Bar' => $array['bar'],
'bar' => $array2['bar']);
What is the best way to test either the $array2 ...
I want to separate the digits of an integer, say 12345, into an array of bytes {1,2,3,4,5}, but I want the most performance effective way to do that, because my program does that millions of times.
Any suggestions? Thanks.
...
I have a multiple select and I made a function to check several parameters, each prints a different value in another form:
if ( (tot_v >= 10) || (perc_a < 100) ) {
$("#DA_IDO").val('1');
}
if ( (tot_v > 3) && (tot_v < 10) && (perc_a == 100) ) {
$("#DA_IDO").val('2');
}
if ( (tot_v <= 3) && (perc_a == 100) ) {
$("#DA_IDO").val('3')...
I have the following array:
votes_array = [["2", "1"], ["2", "4"], ["4", "3"], ["3", "4"], ["1", "N"], ["3", "1"], ["1", "2"], ["4", "1"], ["0", "1"], ["0", "2"], ["1", "3"], ["1", "4"]]
And I want to create a new array (or hash) that stores the votes_array items by their first option so that the new array looks like this:
candidate_...
Is there a standard method to create a new array from a two dimensional array so that array[x][y] would be accessed as [y][x] on the new array?
For example, from:
[ [00,01,02,03,04,05],
[10,11,12,13,14,15],
[20,21,22,23,24,25] ]
Would become:
[ [00,10,20],
[01,11,21],
[02,12,22],
[03,13,23],
[04,14,24],
[05,15,25] ]
...