Given the following sample array, how can I find all permutations of times available such that the amountNeeded is satisfied? In others words the follow array should produce the following:
Available on 2008-05-14 from 08:00 to 08:10 using resource 10 and 13
Available on 2008-05-14 from 08:10 to 08:20 using resource 10 and 13
pri...
I recently ran across some 3rd party C# code which does the following:
public int RecvByteDataFromPrinter(ref byte[] byteData)
{
byte[] recvdata = new byte[1024];
///...fills recvdata array...
byteData = recvdata;
return SUCCESS;
}
What does the line "byteData = recvdata" actually do in this case?
It appears tha...
public Int64 ReturnDifferenceA()
{
User[] arrayList;
Int64 firstTicks;
IList<User> userList;
Int64 secondTicks;
System.Diagnostics.Stopwatch watch;
userList = Enumerable
.Range(0, 1000)
.Select(currentItem => new User()).ToList();
arrayList = userList.ToArray();
watch = new Stopwatch();
wa...
File fil = new File("Tall.txt");
FileReader inputFil = new FileReader(fil);
BufferedReader in = new BufferedReader(inputFil);
int [] tall = new int [100];
String s =in.readLine();
while(s!=null)
{
int i = 0;
tall[i] = Integer.parseInt(s); //this is line 19
System.out.println(tall[i]);
s = in.readLine();
}
in.close();
...
Hi,
I am pulling data out of an old-school ActiveX in the form of arrays of doubles. I don't initially know the final number of samples I will actually retrieve.
What is the most efficient way to concatenate these arrays together in C# as I pull them out of the system?
...
Okay i am working on someone elses code. They do alot of this:
char description[256];
description[0]=0;
I know this would put a \0 in the first spot of the character array. But is this even a safe way to erase a string?
Also visual studio keeps reporting memory leaks, and i've pretty much tied this done to the strings that are used.
...
I've written a Korn Shell script that sets an array the following way:
set -A fruits Apple Orange Banana Strawberry
but when I'm trying to run it from within cron, it raises the following error:
Your "cron" job on myhost
/myScript.sh
produced the following output:
myScript.sh: -A: bad option(s)
I've tried many crontab syntax vari...
( can't believe this hasn't been asked in SO yet... )
How can I remove duplicate values from an array in PHP?
...
How can I remove duplicate values from a multi-dimensional array in PHP?
Example array:
Array
(
[0] => Array
(
[0] => abc
[1] => def
)
[1] => Array
(
[0] => ghi
[1] => jkl
)
[2] => Array
(
[0] => mno
[1] => pql
)
[3] => Array
(
[0] => abc
[1] => def
)
[4] => Array
...
How can I initialize an const / static array of structs as clearly as possible?
class SomeClass
{
struct MyStruct
{
public string label;
public int id;
};
const MyStruct[] MyArray = {
{"a", 1}
{"b", 5}
{"q", 29}
};
};
...
I'm trying to transform each element of a numpy array into an array itself (say, to interpret a greyscale image as a color image). In other words:
>>> my_ar = numpy.array((0,5,10))
[0, 5, 10]
>>> transformed = my_fun(my_ar) # In reality, my_fun() would do something more useful
array([
[ 0, 0, 0],
[ 5, 10, 15],
[10,...
I have a simple function in which an array is declared with size
depending on the parameter which is int.
void f(int n){
char a[n];
};
int main() {
return 0;
}
This piece of code compiles fine on GNU C++, but not on MSVC 2005.
I get the following compilation errors:
.\main.cpp(4) : error C2057: e...
Is it advisable to use arrays in Javascript using tens of thousands of indexes?
I have a database which contains a table of static data, meaning that it will never change. In this case would it be advisable to convert this table to a javascript array and look the info up in there when needed? Is this bad practice?
The table in question...
I have an object that implements ArrayAccess, Iterator and Countable. That produces a nigh-perfect array masking. I can access it with offsets ($object[foo]), I can throw it into a foreach-loop, and many other things.
But what I can't do is give it to the native array iterator functions (next(), reset(), current(), key()), even though I...
I have a SUM array formula that has multiple nested IF statements, making it very inefficient. My formula spans over 500 rows, but here is a simple version of it:
{=SUM(IF(IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17>0,
IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17,0))}
As you can see, the first half of the formula checks where the array is greater t...
I ran into this bug where an element of an array, if its index is the string "0", is inaccessible.
It's not a bug with unserialize, either, as this occurred in my code without invoking it.
$arr = unserialize('a:1:{s:1:"0";i:5;}');
var_dump($arr["0"]); //should be 5, but is NULL
var_dump($arr[0]); //maybe this would work? no. NULL
...
I had this question earlier and it was concluded it was a bug in 5.2.5. Well, it's still broken in 5.2.6, at least for me:
Please let me know if it is broken or works for you:
$obj = new stdClass();
$obj->{"foo"} = "bar";
$obj->{"0"} = "zero";
$arr = (array)$obj;
//foo -- bar
//0 -- {error: undefined index}
foreach ($arr as $key=>...
Hello, I am a bit new to Perl, but here is what I want to do:
my @array2d;
while(<FILE>){
push(@array2d[$i], $_);
}
It doesn't compile since @array2d[$i] is not an array but a scalar value.
How sould I declare @array2d as an array of array?
Of course, I have no idea of how many rows I have.
...
I'm generating titles out of a few other fields, and want the "right" way to do:
Me.Title.Value = Join(Array([Conference], [Speaker], partstr), " - ")
Except any of [conference], [speaker] or partstr might be null, and I don't want the extra "-"'s. Are there any functions that'll make this job straightforward?
...
I'm a little lost (still working with Ron Jeffries's book). Here's a simple class:
public class Model{
private String[] lines;
public void myMethod(){
String[] newLines = new String[lines.length + 2];
for (i = 0, i <= lines.length, i++) {
newLines[i] = lines[i];
}
}
}
I have another cla...