/** * This method tests the creation of an empty list. */ public function testEmpty() { //$this->markTestIncomplete(); $p0 = IHashSet\Type::empty_(); $this->assertInstanceOf('\\Saber\\Data\\IHashSet\\Type', $p0); $p1 = $p0->unbox(); $e1 = 0; $this->assertInternalType('array', $p1); $this->assertCount($e1, $p1); }
/** * This method returns the latter value should the former value evaluates * to null. * * @access public * @static * @param IHashSet\Type $xs the value to be evaluated * @param IHashSet\Type $ys the default value * @return IHashSet\Type the result */ public static function nvl(IHashSet\Type $xs = null, IHashSet\Type $ys = null) : IHashSet\Type { return $xs ?? $ys ?? IHashSet\Type::empty_(); }
/** * This method returns an array list containing only unique items from the specified * array list (i.e. duplicates are removed). * * @access public * @static * @param IArrayList\Type $xs the array list to be processed * @return IArrayList\Type an array list with the duplicates * removed */ public static function nub(IArrayList\Type $xs) : IArrayList\Type { $zs = IHashSet\Type::empty_(); return IArrayList\Module::filter($xs, function (Core\Type $x, IInt32\Type $i) use($zs) : IBool\Type { if ($zs->__hasItem($x)) { return IBool\Type::false(); } $zs->putItem($x); return IBool\Type::true(); }); }