Questions tagged [associative]

This tag is used mostly regarding associative arrays (but better use tag "associative-array" for that) and sometimes in the mathematic sense of tag "associativity", the associative property of binary operations.

435 questions
3
votes
1 answer

dynamic associative array in d

I want an associative array in d programming language. The key is a struct with two shorts. Easy so far. struct kie { short a; short b; } short[kie] possibles; Problem is I want to hold more than value per key. Dynamic would be useful so it can…
3
votes
1 answer

awk associative array with pattern as index

what would be the best solution to have awk store searched pattern along with lines where it was found in an array.. do i need a shell script for that or it can be done using only awk.. so for example if i search for word 'guitar', it makes an array…
branquito
  • 3,864
  • 5
  • 35
  • 60
3
votes
1 answer

How to transfer PHP array of associative arrays to javascript?

In my PHP-side I have an array of associative arrays like so: Array ( [0] => Array ( [resultId] => 15 [testId] => 4 [accountId] => 35 [score] => 50 [standard_deviation] => 0.5 [answer_time]…
jjepsuomi
  • 4,223
  • 8
  • 46
  • 74
2
votes
3 answers

Simplest way to print out comma seperated of an assoc array column in PHP (from MYSQL)

I have a mysql fetch that is populating an associative array with columns from the DB. One of the columns names is AMOUNT. so it looks like this: Array ( [0] => Array ( [ID] => 259 [YEARMONTH] => 201105 [AMOUNT] => 54 [VALUE] => 12 ) [1] => Array (…
Ted
  • 3,805
  • 14
  • 56
  • 98
2
votes
1 answer

Why do the `man bash` pages state the `declare` and `local` `-n` attribute "cannot be applied to array variables", and yet it can?

Why does local -n work on array variables when the manual explicitly says it does not? Is the manual wrong? Is this relying on some sort of bash "undefined behavior?" Is the manual out-of-date? Am I missing something? Here is the information I'm…
Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
2
votes
2 answers

Serializing a Javascript object with contained arrays to json?

I have a javascript object that contains a few objects that contain associative arrays. I've been trying to use the json2.js library's stringify function but the output doesn't contain the arrays held in the contained object members. In my code I…
gman060692
  • 23
  • 1
  • 4
2
votes
1 answer

How does C++ associative containers iterator increment work?

For such C++ STLs associative containers like std::set, std::multiset, std::map or std::multimap iterators. How iteratorName++/iteratorName-- works? Does each element have 2 pointers for the very less/more than itself? If so, how does it keep such…
Ahmed Salah
  • 851
  • 2
  • 10
  • 29
2
votes
3 answers

Expression evaluation in C

#include int main(){ int x = 4; int y = 3; int z; z = x---y; printf("%d" , z); return 0; } The gcc compiler in Linux Mandriva evaluates it as (x--)-y. I am confused as to why is it…
Pritpal
  • 571
  • 1
  • 6
  • 11
2
votes
1 answer

How to delete rows and columns from an associative NxN matrix in O(n) in C++?

I have an associative NxN matrix and a vector containing all columns: std::map> A; std::vector columns; //this has size n An element would look like this: A["abc"]["bcd"] = 2 I want to remove the…
Miklos
  • 101
  • 2
  • 11
2
votes
2 answers

incompatible types in assignment of 'std::string {aka std::basic_string}' to

int main() { std::string my_string= "16657"; std::map m_msg_int; std::string arrId[2]; arrId[0] = "ABC"; arrId[1] = "XYZ/CDE"; m_msg_int[my_string] = arrId[2]; std::cout<<"MSGID"<
2
votes
3 answers

Creating an associative array with random values PHP

I am trying to generate an associate array with random values. For example, if I give you this string: something, anotherThing, foo, bar, baz (the length of the string is dynamic - so there could be 10 items, or 15); I would like to create an array…
2
votes
3 answers

PHP mixed associative array how to get values in foreach loop

Well I have something like $Arr1 = array("a1" => array("a1b", "a1b"), "a2" => array("a2b", "a2b"), "a3", "a4", "a5" => array("a5b", "a5b") ); meaning that "a3" and "a4" are keys without…
giacoder
  • 980
  • 8
  • 21
2
votes
4 answers

Php query into json

I am querying my database Select * from Customer the customer tables holds Name,Surname Address,age. I want to be able to transform the query into a json object in the following object: Customer: [ {Name:"john", Surname:"Beta" ,Age:"23"}, …
7dr3am7
  • 755
  • 1
  • 8
  • 21
2
votes
2 answers

bash associative arrays--variable containing value pair

I have a file that looks like this: stringtests (6 tests) alphatests (1 tests) arraytests (100 tests) I can extract and translate into: ["stringtests"]="6" ["alphatests"]="1" ["arraytests"]="100" I place these in a variable ("tests"): ~>…
Sean Walton
  • 123
  • 2
  • 11
2
votes
1 answer

How to use a complex associative array in javascript?

I need this table http://code.google.com/apis/chart/docs/gallery/qr_codes.html#details in my program and I'm not even sure if an associative array is the way to go. Given the type (numeric/alphanumeric), number of characters and EC (error…
Mr Rab Lorcs
  • 23
  • 1
  • 3