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
7
votes
3 answers

What is the difference between array_udiff_assoc() and array_diff_uassoc()?

What is the difference between array_udiff_assoc() and array_diff_uassoc()? For array_udiff_assoc(), I have this code: function myfunction($v1,$v2) { if ($v1===$v2) { return 0; } return 1; } $a1 = ["a" => "Cat", "b" => "Dog",…
php.khan
  • 1,224
  • 1
  • 12
  • 21
7
votes
1 answer

Will Objective-C runtime release retained associative references for user?

When some codes like this: objc_setAssociatedObject ( obj, &key, val, OBJC_ASSOCIATION_RETAIN ); Do I need to call related objc_setAssociatedObject ( obj, &key, nil, OBJC_ASSOCIATION_RETAIN ); to release the retained value? Does…
cxa
  • 4,238
  • 26
  • 40
7
votes
3 answers

Can Perl 6 use the % sigil for something other than a Hash?

The Perl 6 docs on variables notes that the % sigil can be used with types that do the Associative role. It specifically mentions Pair, Hash, and Map. But, how would I get a Pair into a variable with the %? If I use a type constraint I get a curious…
brian d foy
  • 129,424
  • 31
  • 207
  • 592
7
votes
1 answer

Error assigning associative array key with embedded period

I have a simple shell script in which I am trying to assign a value to an associative array where the key value has one or more "." characters in its value. #!/bin/bash X="my.key" Y="my.val" ARRAY[$X]=$Y When I run this I get the following error…
6
votes
2 answers

How to get and use associative array from YAML to action in Symfony?

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…
quardas
  • 651
  • 3
  • 10
  • 23
6
votes
4 answers

Are JavaScript arrays associative?

For instance, if I do a[1000000]=1; will it use memory for 1000000 elements or just for this one?
Lem0n
  • 77
  • 1
6
votes
2 answers

ASP print out array

I would like to print out the data, for debugging purpose. Data format would be like this cntryCode = resArray("COUNTRYCODE") business = resArray("BUSINESS") ' Payer's business name. shipToName =…
i need help
  • 2,386
  • 10
  • 54
  • 72
5
votes
2 answers

How do I append to an alist in scheme?

Adding an element to the head of an alist (Associative list) is simple enough: > (cons '(ding . 53) '((foo . 42) (bar . 27))) ((ding . 53) (foo . 42) (bar . 27)) Appending to the tail of an alist is a bit trickier though. After some experimenting,…
troelskn
  • 115,121
  • 27
  • 131
  • 155
5
votes
3 answers

Creating An Associative Multi Dimensional Array from loop in PHP

How can I create an array like the following in PHP from a database result set using a loop: Array ( [T] => Array ( [0] => Array ( [id] => 1 [name] => Timer …
Billy
  • 788
  • 1
  • 8
  • 17
5
votes
4 answers

Does Perl have an associative array type that can have any type of keys?

It seems that Perl can only have strings as the keys of a hash. (Has this been changed in a certain version of Perl?) It is very limiting to only be able to use strings as the key. What if I wanted an object or an array to be the key? In Python…
user553702
  • 2,819
  • 5
  • 23
  • 27
5
votes
2 answers

How to make a JQuery associative array from a HTML unordered list

Currently in my JQuery script I have a hard coded array: var arrayList = [ {"id":"1","category":"foo1","title":"bar1","image":"images/foobar1.gif"}, {"id":"2","category":"foo2","title":"bar2","image":"images/foobar2.gif"}, …
dbach
  • 163
  • 3
  • 12
5
votes
0 answers

Compare guarantees for insert with hint for ordered associative containers

I want to insert new (unique) element into known place (generally somewhere in the middle) of an ordered associative container std::set/std::multiset/std::map/std::multimap using insert (w/ hint) or emplace_hint. During insertion operation I…
Tomilov Anatoliy
  • 15,657
  • 10
  • 64
  • 169
5
votes
2 answers

How is Associative Reference implemented?

I saw a very good sample here: Subclass UIButton to add a property What is it? You can't add object to a category. But now with this trick you can. So what is it? How does it work? Objective-c object already have some constant number of ivar…
Anonymous White
  • 2,149
  • 3
  • 20
  • 27
4
votes
2 answers

PHP multidimensional array (usort)

I have an associative array like this Array ( ["News 1"] => Array ( [text] => tests [language] => [advertiserCompetitionScale] => 5 [avgSearchVolume] => 7480000 …
Alexis
  • 1,825
  • 4
  • 23
  • 28
4
votes
6 answers

C++ associative containers - why doesn't the standard defines methods to exchange and replaces keys?

I need to replace specific key values, while the rest of the value_type is left untouched. What I actually need to do, is copy the value, erase the entry and insert it with changed key value again. This is absolutely bad. I need to copy the whole…
0xbadf00d
  • 17,405
  • 15
  • 67
  • 107
1 2
3
28 29