This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# my third attempt | |
module EventSystem | |
# リスナーレジストリ | |
# イベント名 Symbol をキーとして、 | |
# 関心を示したオブジェクトの ID の配列を持つ。 | |
# それぞれのオブジェクトは Event モジュールを include している。 | |
@@registry = Hash.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# my second attempt | |
require 'weakref' | |
module Event | |
# イベント名 Symbol をキーとして、 | |
# 関心を示したオブジェクトへの WeakRef を持つ。 | |
# オブジェクトは Event モジュールを include している。 | |
@@event_objects_map = Hash.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# my third attempt | |
module EventSystem | |
# リスナーレジストリ | |
# イベント名 Symbol をキーとして、 | |
# 関心を示したオブジェクトの ID の配列を持つ。 | |
# それぞれのオブジェクトは Event モジュールを include している。 | |
@@registry = Hash.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <windows.h> | |
/* LARGE_INTEGER を表示する */ | |
#define disp_large_int(x) printf(#x " = %lld\n", x.QuadPart) | |
/* QueryPerformanceFrequency と ...Counter を使って | |
Sleep(1000) を実行する間にたった時間を表示する */ | |
int main(int argc, char **argv) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
template <typename T> | |
T inject_plus(T v) | |
{ return v; } | |
template <typename T, typename ... Rest> | |
T inject_plus(T v, Rest ... rest) | |
{ | |
return v + inject_plus(rest...); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <typeinfo> | |
using namespace std; | |
// コマンドオブジェクト、Job のインターフェース。 | |
// これのポインタを使ってアクセスする。 | |
class IJob { | |
public: | |
// インスタンス生成テンプレート関数。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sstream> | |
#include <iostream> | |
#include <cctype> | |
#include <list> | |
#include <vector> | |
#include <string> | |
#include <iterator> | |
#include <algorithm> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
label: | |
int i(10); | |
cout << i << endl; | |
i = 20; | |
goto label; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 数を空白くぎりで入力すると和を計算します */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int calculate_sum(const char *line) | |
{ | |
int sum = 0; | |
char *copy = strdup(line); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void SpellingChecker::Check (Glyph* glyph) { | |
Character* c; | |
Row* r; | |
Image* i; | |
if (c = dynamic_cast<Character*>(glyph)) { | |
// analyze the character | |
} else if (r = dynamic_cast<Row*>(glyph)) { | |
// prepare to analyze r's children |
OlderNewer