예제 #1
0
 public function testMake()
 {
     $array = CArray::make();
     $this->assertTrue($array->getSize() == 0);
     $array = CArray::make(10);
     $this->assertTrue($array->getSize() == 10);
     $array = CArray::makeDim2(2, 3);
     $this->assertTrue($array->getSize() == 2 && $array[0]->getSize() == 3 && $array[1]->getSize() == 3);
     $array = CArray::makeDim3(2, 3, 2);
     $this->assertTrue($array->getSize() == 2 && $array[0]->getSize() == 3 && $array[1]->getSize() == 3 && $array[0][0]->getSize() == 2 && $array[0][1]->getSize() == 2 && $array[0][2]->getSize() == 2);
     $array = CArray::makeDim4(2, 3, 2, 1);
     $this->assertTrue($array->getSize() == 2 && $array[0]->getSize() == 3 && $array[1]->getSize() == 3 && $array[0][0]->getSize() == 2 && $array[0][1]->getSize() == 2 && $array[0][2]->getSize() == 2 && $array[0][0][0]->getSize() == 1 && $array[0][0][1]->getSize() == 1);
 }
예제 #2
0
 /**
  * Creates a four-dimensional OOP array.
  *
  * @param  int $lengthDim1 The length of the array at the first level.
  * @param  int $lengthDim2 The length(s) of the array(s) at the second level.
  * @param  int $lengthDim3 The length(s) of the array(s) at the third level.
  * @param  int $lengthDim4 **OPTIONAL. Default is** `0`. The length(s) of the array(s) at the fourth level.
  *
  * @return CArrayObject The new array.
  */
 public static function makeDim4($lengthDim1, $lengthDim2, $lengthDim3, $lengthDim4 = 0)
 {
     return to_oop(CArray::makeDim4($lengthDim1, $lengthDim2, $lengthDim3, $lengthDim4));
 }