orieg/php-judy — Issue #1: count() and size() returns sum - intentional?
Author: pgn84
Created: 2012-01-24 16:31:39+00:00
State: open

Given two Judy instances, how can the non-static methods size() and count() on any of the two instances be returning what seems to be **the sum of all elements on judy arrays in the same PHP process?**

Is this intentional? Nothing seems to be pointing to this in documentation. Did i miss something? See Unit test below. testSizeConsistent() fails, others pass, including testIsSizeSum()

```php
class JudyTest extends PHPUnit_Framework_TestCase {

private $a, $b;

public function setUp() {

$this->a = new Judy(Judy::STRING_TO_MIXED);
$this->b = new Judy(Judy::STRING_TO_MIXED);
}

public function testSizeConsistent() {

// lets populate a
$this->a->offsetSet("foo", "bar");
$this->a->offsetSet("another", "value");

// b couldn't have possibly grown?
$this->assertTrue($this->b->size() === 0);

}

public function testSizeZero() {

$this->assertTrue($this->a->size() === 0);
$this->assertTrue($this->b->size() === 0);

}

public function testIsSizeSum() {

$this->a->offsetSet("foo", "bar");
$this->a->offsetSet("another", "value");
$this->b->offsetSet("third", "..");

$this->assertTrue($this->b->size() === 3);

}

}
```

( i am using the latest "beta" stability Judy array php module from pecl (pecl.php.net/Judy-0.1.2) and the latest libjudy available in macports ( judy @1.0.5 (devel) ) on OS X Lion )

thanks! Andras

ps: i have posted this at http://stackoverflow.com/questions/8973744/php-judy-array-size-count-not-what-it-claims-to-be too, no answers so far - feel free to respond there if this is indeed intentional.