當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Graph::getInstance方法代碼示例

本文整理匯總了PHP中Graph::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Graph::getInstance方法的具體用法?PHP Graph::getInstance怎麽用?PHP Graph::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Graph的用法示例。


在下文中一共展示了Graph::getInstance方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testUnprogrammedKeyMissingEnabledUsingConstructor

 public function testUnprogrammedKeyMissingEnabledUsingConstructor()
 {
     $graph = Graph::getInstance(true);
     $nodes = $graph->getNodes();
     $this->assertNotNull($nodes[ord('')]);
     $expected = array('Up' => '8', 'Right' => ' ', 'Down' => 'I', 'Left' => '>');
     $this->assertEquals($expected, $nodes[ord('')]);
 }
開發者ID:shoaibi,項目名稱:speed-typing,代碼行數:8,代碼來源:GraphTest.php

示例2: __construct

 public function __construct($sentence, $enableUnProgrammedKeyForTraversal = false)
 {
     if (!is_string($sentence)) {
         throw new InvalidArgumentException("Sentence should be string");
     }
     if (empty($sentence)) {
         throw new InvalidArgumentException("Sentence should not be empty");
     }
     $this->sentence = $sentence;
     $graph = Graph::getInstance($enableUnProgrammedKeyForTraversal);
     $this->nodes = $graph->getNodes();
     $this->fullPath = array();
 }
開發者ID:shoaibi,項目名稱:speed-typing,代碼行數:13,代碼來源:KeySequenceGenerator.php

示例3: testProcessWithComplicatedStringWithTraversal

 /**
  * @depends testProcessWithComplicatedStringWithSentenceGenerationFromSequence
  */
 public function testProcessWithComplicatedStringWithTraversal()
 {
     $sentence = 'AA qu!c7 br0wn (fox) {jumps} ov:e> a la,zy_[dog].';
     $generator = new KeySequenceGenerator($sentence);
     $generator->process();
     $sequence = $generator->printSequences(true, true);
     $this->assertEquals(2659, strlen($sequence));
     $sequenceTokens = explode(PHP_EOL, $sequence);
     $graph = Graph::getInstance();
     $nodes = $graph->getNodes();
     $node = $nodes[ord($sequenceTokens[0])];
     for ($i = 1; $i < count($sequenceTokens); $i++) {
         if ($sequenceTokens[$i] === KeyPress::ENTER) {
             continue;
         }
         if (in_array($sequenceTokens[$i], array(KeyPress::UP, KeyPress::RIGHT, KeyPress::DOWN, KeyPress::LEFT))) {
             $next = $i + 1;
             $this->assertEquals($node[$sequenceTokens[$i]], $sequenceTokens[$next]);
             $node = $nodes[ord($sequenceTokens[$next])];
         }
     }
 }
開發者ID:shoaibi,項目名稱:speed-typing,代碼行數:25,代碼來源:KeySequenceGeneratorTest.php


注:本文中的Graph::getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。