Is there some way to delay defining the size of an array until a class method or constructor?
What I'm thinking of might look something like this, which (of course) doesn't work:
class Test
{
private:
int _array[][];
public:
Test::Test(int width, int height);
};
Test::Test(int width, int height)
{
_array[width][he...
As a side result of testing some code I wrote a small function to compare the speed of using the array.push method vs direct addressing (array[n] = value). To my surprise the push method often showed to be faster especially in Firefox and sometimes in Chrome. Just out of curiosity: anyone has an explanation for it?
You can find the test ...
I'm just curious how this is done directly by browsers. I heard that .length property of Array in Javascript Engines in fact uses invisible setters and getters to achieve functionality of ECMA-s standard that says: "whenever the length property is changed, every property whose name is an array index whose value is not smaller than the ne...
I have an array of float values and want the value and more importantly the position of the maximum four values.
I built the system originally to walk through the array and find the max the usual way, by comparing the value at the current position to a recorded max-so-far, and updating a position variable when the max-so-far changes. T...
Using Php. Need:
On String Input: "Some terms with spaces between"
OutputArray <String>: {Some, terms, with, spaces, between}
...
Was looking at some code earlier, and am thinking that there has to be a more elegant way of writing this....
(returnVar.Warnings is a string array, it could be returned as any size depending on the number of warnings that are logged)
For Each item In items
If o.ImageContent.ImageId = 0 Then
ReDim Preserve returnVar.Warning...
I have an array of items and I would like to sort on one of their properties.
I can access the items property using "item.Fields["FieldName"].Value" the property is returned as a string but I can cast it to an int.
I had a look at OrderBy<> but I have no idea of how to use it.
...
Say you have a 10 element indexed array and you want to place an element somewhere in the middle (say index 3). Then I want to have the rest of the array shift and thus be 11 elements long. Is there an easy way to do this?
I am surprised there is no put() function or something.
I know it would be easy enough to do this with a combinati...
I am trying to create an array of pointers. These pointers will point to a Student object that I created. How do I do it?
What I have now is:
Student * db = new Student[5];
But each element in that array is the student object, not a pointer to the student object.
Thanks.
...
I use an extension method to convert float arrays into byte arrays:
public static unsafe byte[] ToByteArray(this float[] floatArray, int count)
{
int arrayLength = floatArray.Length > count ? count : floatArray.Length;
byte[] byteArray = new byte[4 * arrayLength];
fixed (float* floatPointer = floatArray)
{
fixed ...
If I have an int array structured like this:
private int[][] map = new int[400][400];
And I try to retrieve
map[100][200]
And that element isn't initialized, will i get a compiler/runtime error or will it return null? And is there any function to check if a given element/index exists/has been set?
...
Hello
My issue involves an array that is apparently not nil but when I try to access it, it is.
The array is returned from a find on an active record. I have confirmed it is in fact an array with the .class method
@show_times = Showing.find_showtimes(params[:id])
@show_times.inspect =>shows that the array is not empty and is a multidi...
I was talking to a person today who mentioned he used arrays when calling parameters or for other reasons when pulling data from the database etc.
Basically my question is: how would you use arrays in web development?
For example:
If you had a url like this (a social dating site)
http://www.example.com/page.php?sid=1&agefrom=30&a...
Is there any easy way to remove the contents of one array from another?
...
In Java, the java.util.Arrays class have several static toString(...) methods that take an array and return its string representation (i.e. the string representation of the contents of the array separated by commas and the whole representation enclosed in square brackets -- e.g. "[1, 2, 3]").
Is there an equivalent method/functionality ...
I need to hard code an array of points in my C# program. The C-style initializer did not work.
PointF[] points = new PointF{
/* what goes here? */
};
How is it done?
...
var a = [1,4,5];
var e = a.length--;
Here e variable will contain 5. But if I do:
var e = a.length-=1;
Here e will contain 2 the number of elements array.
So the first is a language 'tip' to simulate a pop() array methods?
In the language syntax doing:
a--
or
a-=1
is semantically the same.
...
Basically, I have a UISearchBar searching an NSMutableArray of stories that make up an RSS feed, and when you select a story, it loads in my app's UIWebView. It's difficult to explain, but I have a list of entries 1, 2, 3, and 4 and you search for '4'. 4 will be the first entry in the now-filtered list of data, right? You'd think that by...
Hi, I need to retrieve data from several rows and then insert the results into an enumerated array so then I can use a "for" loop to echo it...
I have this (I already connected to the database):
$genres_sql = 'SELECT genreID FROM genres WHERE imdbID = ?';
if ($stmt->prepare($genres_sql)) {
// bind the query parameters
$stmt->bind_par...
EDIT: apparently some of this isn't allowed/has changed in various C standards. For my own hypothetical benefit, let's pretend we're using gcc test.c with no standard or warning options.
In particular I'm looking at the under-the-hood specifics. I've added my current understanding. Am I right?
char **c1; //Size for a pointer is al...