associative

How do you print an associative array in dtrace?

The question pretty much sums it up. "dtrace 'print an associative array'" has exactly one google hit and the similar searches are equally useless. EDIT: If I were to use an aggregation, I'm not aware that I'd still be able to remove entries. My application requires that I be able to do things like: file_descriptors[0] = "stdin" fil...

Operator precedence and associativity in a parser (Haskell)

I am trying to extend a recursive-descent parser to handle new operators and make them associate correctly. Originally there were only four operators (+ - / *) and they all had the same precedence. The function I am looking at is the parseExpRec function: parseExpRec :: Exp -> [Token] -> (Exp, [Token]) parseExpRec e [...

sort associative array in awk - help?

Hi all, I have an associative array in awk that gets populated like this... chr_count[$3]++ When I try to print my chr_counts I use this: for (i in chr_count) { print i,":",chr_count[i]; } But not surprisingly, the order of i is not sorted in any way. Is there an easy way to iterate over the sorted "keys" of chr_count? ...

sort associative array PHP

Here's my array, how do I sort it by saleref? Array ( [xml] => Array ( [sale] => Array ( [0] => Array ( [saleref] => 12345 [saleline] => 1 [product] => producta ...

javascript "associative" array access

Hello I have a simple simulated aarray with two elements: bowl["fruit"]="apple"; bowl["nuts"]="brazilian"; I can access the value with an event like this: onclick="testButton00_('fruit')">with `testButton00_` function testButton00_(key){ var t = bowl[key]; alert("testButton00_: value = "+t); } However whenever I try to acc...

Are JavaScript arrays associative?

For instance, if I do a[1000000]=1; will it use memory for 1000000 elements or just for this one? ...

How do you traverse and store XML in Blackberry Java app?

I'm having a problem accessing the contents of an XML document. My goal is this: Take an XML source and parse it into a fair equivalent of an associative array, then store it as a persistable object. the xml is pretty simple: <root> <element> <category_id>1</category_id> <name>Cars</name> </element> <element> <category_id>2...

In Rails: How can I turn off caching for a particular activerecord database table?

I have an associative table (scripts_runs) (has_many, through) that carries a status column ('started', 'ready to parse', 'completed' ). The started and ready to parse states are signaled by 'flag' files from distributed executions of the scripts pickedup periodically (20 seconds). The completed status is written directly to the assoc...

Summarize object area with a Hash in Ruby

require 'sketchup' entities = Sketchup.active_model.entities summa = Hash.new for face in entities next unless face.kind_of? Sketchup::Face if (face.material) summa[face.material.display_name] += face.area end end Im trying to get the structure in the array as such: summa { "Bric...

associative list python

Dear all, i am parsing some html form with Beautiful soup. Basically i´ve around 60 input fields mostly radio buttons and checkboxes. So far this works with the following code: from BeautifulSoup import BeautifulSoup x = open('myfile.html','r').read() out = open('outfile.csv','w') soup = BeautifulSoup(x) values = soup.findAll('input',...

symmetrical associative array search by key and value

I need to describe an associative array in which to search, you can use the key and value. With functions add, delete, getBy1st (search by key), getBy2nd (search by value). For example in C++: symmap<std::string, int> m; m.insert(make_pair<std::string,int> ("hello", 1)); m.insert(make_pair<std::string,int> ("wow", 2)); ... m.getBy1st(...

Associative Arrays/Object - getting values with dot notation

Hi, I don't really get why this isn't working: thing = { img78:{ exifmanufacturer:"Canon", exifmodel:"Canon EOS 450D", exifexposuretime:"1/125", exiffstop:"71/10", exifiso:"200"}, img79:{ exifmanufacturer:"Canon", exifmodel:"Canon EOS 550D", exifexposuretime:"1/125", exiffstop:"71/10", exifiso:"100"}, img80:{ exifmanufacturer:"Canon", ...

Hashtables not really working.

Hi! I'm doing some web development, and I'd like to use an associative array in my code. I've used hashtables in other design work, and they definitely do the trick. However, when I try to call "var coms = new Hashtable();", I get errors stating that there is no class hashtables. I've read that in JS all objects ARE hashtables, so I su...

How to remove duplicate values from an associative array based on a specific value?

Hi there! I have an array that looks just like that: array(3) { ["fk_article_id"]=> string(1) "4" ["first_name"]=> string(6) "Ulrike" ["last_name"]=> string(10) "Grasberger" } array(3) { ["fk_article_id"]=> string(1) "9" ["first_name"]=> string(5) "Frank" ["last_name"]=> string(9) "Neubacher" } array(3) { ["fk_article_id"]=> string(3...

Accessing associative arrays in PHP

Hello, I want to access the index 'memo' in the associative array in PHP below $variables["thelistitems"]; print_r($variables["thelistitems"]); Output Array ( [0] => Array ( [productid] => prod:c6dbdd62-dc13-6421-5a94-c8cd871a59d3 [memo] => dummy [taxable] => 0 [unitweight] => 0 [u...

how combine multiple arrays into a single associate array using the arrays as keys

I have 2 arrays that i would like to loop through and combine into an associative array. I would like to use the 2 arrays as the keys for the new associative array. I am new to php so any and all help would be appreciated. $id = array( 2, 4); $qty = array( 5, 7); array('id' => , 'qty' => ); Thanks in advance I would like to output...

how to get and use associative array from YAML to action in symfony framework 1.4.8

Ive got in app.yml some configration data, and I want to foreach them in action. I try do this by get them by sfConfig::get('app_datas') but it fails. Lets show them in details: YAML: all: datas: foo: bar foo2: bar2 and in the actions.class.php I try use this code: foreach (sfConfig::get('app_datas') as $key => $value) { ...

Constructing associative containers

I was convinced (until I just tried it a moment ago) that it was possible to instantiate an associative container with array style notation. For example, std::set< int > _set = { 2, 3, 5 }; This isn't the case but I am wondering if there is any other way of bulk initialising a container in the constructor like this? ...

JS associative array with duplicate names

ok, so I have an array like: var myarray = { "field_1": "lorem ipsum", "field_2": 1, "field_2": 2, "field_2": 6 }; as you see there are duplicate names in the array, but with different values. If i go through it like (using jQuery): $.each(myarray, function(key, value) { console.log(key); console.log(myarray[key]); ...

How to sort associative array in Javascript?

Hi, I need to sort associative array by JS for one of my projects. I found this function, that works great in firefox, but unfortunately it doesnt work in IE8, OPERA, CHROME... Cant find the way to make it work in other browsers, or find another function that would fit the purpose. I really appreciate any help. function sortAssoc(aInpu...