当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayList::get方法代码示例

本文整理汇总了PHP中ArrayList::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayList::get方法的具体用法?PHP ArrayList::get怎么用?PHP ArrayList::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayList的用法示例。


在下文中一共展示了ArrayList::get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: notifyObservers

 public function notifyObservers()
 {
     for ($i = 0; $i < $this->observers->size(); $i++) {
         $observer = $this->observers->get($i);
         $observer->update($this->temperature, $this->humidity, $this->pressure);
     }
 }
开发者ID:srinathweb,项目名称:HeadFirstDesignPatternsInPHP,代码行数:7,代码来源:WeatherData.php

示例2: testUpdateElementCheckChanged

 public function testUpdateElementCheckChanged()
 {
     $list = new ArrayList("SomePojo");
     $list->add(new SomePojo(5));
     $list->add(new SomePojo(8));
     $list->get(1)->setField(7);
     $this->assertEqual(5, $list->get(0)->getField());
     $this->assertEqual(7, $list->get(1)->getField());
 }
开发者ID:aeberh,项目名称:php-movico,代码行数:9,代码来源:ListUpdateElementTest.php

示例3: testSortObjectsComparator

 function testSortObjectsComparator()
 {
     $oList = new ArrayList("SampleSortableObject");
     $oList->add(new SampleSortableObject(new String("b")));
     $oList->add(new SampleSortableObject(new String("a")));
     $oList->add(new SampleSortableObject(new String("c")));
     $oList->sort(new SampleSortableObjectComparator());
     $this->assertEqual(new String("c"), $oList->get(0)->getField());
     $this->assertEqual(new String("b"), $oList->get(1)->getField());
     $this->assertEqual(new String("a"), $oList->get(2)->getField());
 }
开发者ID:aeberh,项目名称:php-movico,代码行数:11,代码来源:ListSortTest.php

示例4: testSet

 public function testSet()
 {
     // Remove the following lines when you implement this test.
     $this->assertTrue($this->object->set(2, 69)->toNative() == 2);
     $this->assertTrue($this->object->get(2)->toNative() == 69);
     $this->assertTrue($this->object->indexOf(69) == 2);
 }
开发者ID:robo47,项目名称:BlazeFramework,代码行数:7,代码来源:ArrayListTest.php

示例5: notifyObservers

 /**
  * Se este objeto foi alterado, como indicado pelo método hasChanged, em seguida, 
  * notificar todos os seus observadores e, em seguida, chamar o método clearChanged 
  * para indicar que este objeto não mudou.
  * @param \Prime\util\Object $arg
  */
 public function notifyObservers()
 {
     for ($index = 0; $index < count($this->observers->size()); $index++) {
         $observer = $this->observers->get($index);
         /* @var $observer IObserver */
         $observer->update($this);
     }
     $this->clearChanged();
 }
开发者ID:primephp,项目名称:framework,代码行数:15,代码来源:Observable.php

示例6: testAddAndGetAndIsEmptyAndClear

 /**
  * This method tests the add and the get method
  * of the ArrayList.
  *
  * @return void
  */
 public function testAddAndGetAndIsEmptyAndClear()
 {
     // initialize a new ArrayList
     $list = new ArrayList();
     // check that the ArrayList is empty
     $this->assertTrue($list->isEmpty());
     // add a new element
     $list->add("Test");
     // get the element
     $this->assertEquals("Test", $list->get(0));
     // check that the ArrayList is not empty
     $this->assertFalse($list->isEmpty());
     // remove all elements
     $list->clear();
     // check that the ArrayList is empty
     $this->assertTrue($list->isEmpty());
 }
开发者ID:appserver-io,项目名称:collections,代码行数:23,代码来源:ArrayListTest.php

示例7: calculate

 public function calculate($infix)
 {
     $postfix = new ArrayList();
     $stack = new ArrayList();
     $i = 0;
     $temp = "";
     $type = $this->getType($infix[0]);
     $lasttype = TType::OPERATION;
     $infix = trim($infix);
     while ($i < strlen($infix)) {
         $type = $this->getType($infix[$i]);
         $temp = "";
         //Get Token name
         while ($type == $this->getType($infix[$i])) {
             $temp .= $infix[$i];
             $i++;
             if ($i == strlen($infix) || $type == TType::OPERATION || $infix[$i - 1] == '(') {
                 break;
             }
         }
         //Negatives Vorzeichen zu -1* umgeschrieben (Bsp.: -3 => (-1)*3
         if ($lasttype == TType::OPERATION && $type == TType::OPERATION) {
             if ($temp == '-') {
                 $postfix->add(new Token("-1", TType::NUMBER));
                 $temp = "*";
             } else {
                 $postfix->add(new Token("1", TType::NUMBER));
                 $temp = "*";
             }
         }
         //Fehlender Operator vor Funktionen wird ergänzt
         if ($type == TType::NUMBER && $lasttype == TType::FUNC || $type == TType::FUNC && $lasttype == TType::NUMBER) {
             $i -= strlen($temp);
             $type = TType::OPERATION;
             $temp = "*";
         }
         //Add Token to Tokenlist
         switch ($type) {
             case TType::NUMBER:
                 $postfix->add(new Token($temp, $type));
                 break;
             case TType::OPERATION:
                 for ($j = $stack->size() - 1; $j > -1; $j--) {
                     if ($this->getValue($temp) > $this->getValue($stack->get($j))) {
                         $stack->add($temp);
                         break;
                     } else {
                         $postfix->add(new Token($stack->get($j), TType::OPERATION));
                         $stack->remove($j);
                     }
                 }
                 if ($stack->size() == 0) {
                     $stack->add($temp);
                 }
                 break;
             case TType::FUNC:
                 if (in_array($temp, $this->availableFunc)) {
                     $func = new FunctionC($temp);
                     $sub = substr($infix, $i);
                     $pos = $this->getLastBracket($sub);
                     $sub = substr($sub, 0, $pos);
                     while (strpos($sub, ',') !== false) {
                         $pos2 = strpos($sub, ',');
                         if (strlen($func->term) === false && $temp == "integral(") {
                             $func->term = substr($sub, 0, $pos2);
                         } else {
                             $func->parameters->add($this->calculate(substr($sub, 0, $pos2)));
                         }
                         $sub = substr($sub, $pos2 + 1);
                     }
                     $func->parameters->add($this->calculate($sub));
                     $i += $pos + 1;
                     $postfix->add(new Token(strval($func->calculate()), TType::NUMBER));
                     $type = TType::NUMBER;
                 }
                 if ($this->variable->size() != 0) {
                     foreach ($this->variable->arrayList as $v) {
                         if ($temp == $v->name) {
                             $postfix->add(new Token(strval($v->wert), TType::NUMBER));
                             $temp = "";
                             $type = TType::NUMBER;
                         }
                     }
                 }
                 break;
         }
         $lasttype = $type;
     }
     //Add operation stack to postfix
     for ($j = $stack->size() - 1; $j > -1; $j--) {
         $postfix->add(new Token($stack->get($j), TType::OPERATION));
         $stack->remove($j);
     }
     //Calculate postfix--> result
     /* Lese alle Tokens der postfix Liste nacheinander ein.
      * Schreibe alle Zahlen in einen Stack, wird eine Operation gelesen, so führe die Operation mit den letzten
      * beiden hinzugefügten Zahlen aus, lösche die beiden Zahlen und ersetze sie mit ihrem Ergebnis
      */
     $result = 0.0;
     for ($i = 0; $i < $postfix->size(); $i++) {
//.........这里部分代码省略.........
开发者ID:Bomberus,项目名称:MathParserPHP,代码行数:101,代码来源:math.php

示例8: next

 public function next()
 {
     $object = $this->items->get($this->position);
     $this->position = $this->position + 1;
     return $object;
 }
开发者ID:srinathweb,项目名称:HeadFirstDesignPatternsInPHP,代码行数:6,代码来源:PancakeHouseMenuIterator.php

示例9: getChild

 public function getChild($i)
 {
     return $this->menuComponents->get($i);
 }
开发者ID:srinathweb,项目名称:HeadFirstDesignPatternsInPHP,代码行数:4,代码来源:Menu.php


注:本文中的ArrayList::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。