Skip to content

Instantly share code, notes, and snippets.

@kentatogashi
kentatogashi / gist:6070925
Last active December 20, 2015 04:29
Quick Sort
<?php
function quickSort(&$numArr,$left = 0,$right)
{
if($left >= $right) {
return;
}
swap($numArr,$left,ceil(($left+$right)/2));
$last = $left;
for($i = $left+1;$i<=$right;$i++) {
<?php
/*
* QuickSort
* &$a:リファレンス渡し
* */
function quickSort(&$numArr,$left = 0,$right)
{
//(1)
if($left >= $right) {
return;
<?php
function qs($seq){
if(count($seq) == false)return $seq;
$pivot = $seq[0];
$low = $high = array();
$length = count($seq);
for($i = 1;$i < $length;$i++){
if($seq[$i] < $pivot){
$low[] = $seq[$i];
} else {
@kentatogashi
kentatogashi / gist:6156031
Last active December 20, 2015 15:39
SingletonSample
<?php
class SingletonSample {
/**
* member variable;
* */
private $id;
/**
* constructor
*
<?php
/* class SingletonSample {...} */
?>
<?php
/**
* get instance
*/
$instance1 = SingletonSample::getInstance();
sleep(3);
git clone --recursive git://github.com/zendframework/ZendSkeletonApplication.git
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Application;
<?php
// Test/test.php
namespace Test;
function var_dump($input) {
$input = empty($input) ? 'empty' : $input;
echo('It is private var_dump!! your input is '.$input);
}
<?php
//private var_dump();
function var_dump($input) {
$input = empty($input) ? 'empty' : $input;
echo('It is private var_dump!! your input is '.$input);
}
var_dump('test');
<?php
namespace lib\dummy1;
class Dummy {
public function execute() {
echo "lib/dummy1";
}
}