本文整理汇总了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);
}
}
示例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());
}
示例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());
}
示例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);
}
示例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();
}
示例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());
}
示例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++) {
//.........这里部分代码省略.........
示例8: next
public function next()
{
$object = $this->items->get($this->position);
$this->position = $this->position + 1;
return $object;
}
示例9: getChild
public function getChild($i)
{
return $this->menuComponents->get($i);
}