This may sound really stupid. but I've got a strange problem with the D programming language. When I try to create a new array like this:
import std.stdio;
void main()
{
char[] variable = "value";
writefln(variable);
}
The DMD compiler always gives me this error:
test.d(5): Error: cannot implicitly
convert expression ("...
I currently have the following lua code:
g = engine.CGeometry()
vertexes = {}
vertexes[1] = 0
vertexes[2] = 0
vertexes[3] = 0
vertexes[4] = 0
vertexes[5] = -1
vertexes[6] = 0
vertexes[7] = -1
vertexes[8] = 0
vertexes[9] = 0
print "adding vertexes"
g:SetVertexes(vertexes)
where g...
I have written a page here on using arrays as proper objects with their own methods instead of relying on helper classes like Arrays, Arrays and ArrayUtils.
ints.sort(); // instead of Arrays.sort(ints);
// instead of int[] onemore = ArrayUtils.add(ints, 8);
int[] onemore = ints.add(8);
I am sure I am not the first with this idea but...
I have a small program where I have been trying to create collections of a particular object I have created (Job).
Regardless of whether I am using an array, collection or list, each time I add a new instance of the object to the array/collection/list, it overwrites all previous items with the same object.
For example, let's say Job ha...
I have often thought it would be a good idea to allow the use of arrays as proper objects with their own methods instead of relying on helper classes like Arrays, Arrays and ArrayUtils.
For example:
ints.sort(); // Arrays.sort(ints);
int[] onemore = ints.add(8); // int[] onemore = ArrayUtils.add(ints, 8);
I am sure I ...
Title says it all.
Though the manual says you're better off to avoid a function call, I've also read $array[] is much slower than array_push(). Does anyone have any clarifications or benchmarks?
Thank you!
...
I need to sort two arrays simultaneously, or rather I need to sort one of the arrays and bring the corresponding element of its associated array with it as I sort. That is if the array is [(5, 33), (4, 44), (3, 55)] and I sort by the first axis (labeled below dtype='alpha') then I want: [(3.0, 55.0) (4.0, 44.0) (5.0, 33.0)]. These are ...
I have the following vb.net code to take the values out of a textbox on a webpage (actually space delimited tags) and split them with a space delimiter into an array. This works exactly how I want.
mySample.Tags = tagsTextBox.Text
Dim tags As String = mySample.Tags
Dim tagarray() As String
Dim count As Integer
tagarray = tags.Split(" ")...
I have an array of objects, something like this:
var myArray = [
{ 'name' : 'some name', id: 23131, 'has' : ['dogs'] },
{ 'name' : 'some name 2', id: 8678, 'has' : ['dogs', 'cats'] },
{ 'name' : 'some name 3', id: 2125 , 'has' : ['donkeys', 'goats']},
{ 'name' : 'some name 4', id: 90867, 'has' : ['parrots', 'treasure'] },
...
We wrote some code involving usort which works fine on our development systems (PHP 5.2.8), but are experiencing a problem on our live systems (PHP 5.2.0):
// Sort by distance
usort($locations, 'Interpolator::sortByDistance');
calls the method (within the same class Interpolator):
private static function sortByDistance($a, $b) {
...
How could I go about detecting (returning true/false) whether an ArrayList contains more than one of the same element in Java?
Many thanks,
Terry
Edit
Forgot to mention that I am not looking to compare "Blocks" with each other but their integer values. Each "block" has an int and this is what makes them different.
I find the int of a p...
Hello,
I want to make all objects in an array perform a selector. I've discovered the appropriately named makeObjectsPerformSelector: method, but I have a question with it. If I use it on an array, will it change the existing array or return a new one? If it modifies the existing object, what be the easiest way to return a new array with...
I've got an array like this:
string[] parts = line.Split(',');
string store = parts[0];
string sku = parts[1];
string subcatcode = parts[2];
string price = parts[3];
string date = parts[4];
string desc = parts[5];
I want description to equal the joined value of all the parts with an index of 5 or higher. Will this work or is there a...
If you have an array of java objects which have a primitive type (for example Byte, Integer, Char, etc). Is there a neat way I can convert it into an array of the primitive type? In particular can this be done without having to create a new array and loop through the contents.
So for example, given
Integer[] array
what is the neate...
OK, I've been working on something for a while now, using reflection to accomplish a lot of what I need to do, but I've hit a bit of a stumbling block...
I'm trying to use reflection to populate the properties of an array of a child property... not sure that's clear, so it's probably best explained in code:
Parent Class:
Public Class ...
EDIT: See Below
I have a web service which uses a class of functions in order to return data used in various business processes (via InfoPath).
One of the functions takes a given SQLCommand object and executes it into a SQLDataReader. Now depending on the SQL command text used this may return one or many rows of one or many columns....
The other day, needed to iterate over a subset of an array at a time. Initially, I did this with splice - tearing apart the array was no problem in this case. It would return N elements at a time, or whatever was left at the end of the list. All went well.
Then it turned out I needed the array later. Instead of splice, I switched to...
Given two arrays, is there a fast algorithm for finding all elements in the two that are different? For example, consider two arrays of Keys (as in keyboard keys) structs. One represents the currently depressed keys, and the other represents the keys depressed in the last timestep.
Keys[] oldKeys = LastKeyboardState.GetPressedKeys();
Ke...
I'd like to create an array from range of values within an ArrayList but am getting the error "At least one element in the source array could not be cast down to the destination array type".
Why should the following fail, and what would you do instead?
int[] ints = new int[] { 1, 2, 3 };
ArrayList list = ArrayList.Adapter(ints);
int[]...
I'm doing some Wave file handling and have them read from disk into an array of bytes. I want to quickly copy portions from this byte array into another buffer for intermediate processing. Currently I use something like this:
float[] fin;
byte[] buf;
//fill buf code omitted
for(int i=offset; i < size; i++){
fin[i-offset] = (float) bu...