- 博客(17)
- 收藏
- 关注
原创 设计模式Before-after之代理模式
before.cxx#include #include class Console {public: void write(std::string msg) { std::cout << msg; }};int main(void) { Console console; console.write("hello"); console.write(", "); co
2014-04-01 23:39:23
621
原创 使用 flex & bison 生成科学计算器
scanner.l%{#include #include #define YYSTYPE double#include "parser.h"%}%option noyywrapdigit [0-9]space [\t\n ]number {digit}+(\.{digit}*)?|\.{digit}+abs (?i:abs)exp (?i:exp)log (
2014-03-25 23:38:00
971
原创 设计模式Before-after之享元模式
before.cxx#include #include class ACounter {public: unsigned int count(const std::string &input) { unsigned int count = 0; for (int i = 0; i < input.length(); ++i) { if (input[i] == 'a' ||
2014-03-21 18:22:47
468
原创 设计模式Before-after之单例模式
before.cxx#include class OS {public: const char *getName(void) { return "Microsoft Windows"; } const char *getVersion(void) { return "6.1.7601"; }};OS os;void displayCurrentOSName(vo
2014-03-17 13:55:55
538
原创 设计模式Before-after之装饰模式
before.cxx#include class RobotCat {public: void cry(void) { std::cout << "Meow! Meow! Meow!" << std::endl; }};class RobotCatCanWalk: public RobotCat {public: void walk(void) { std::cou
2014-03-17 10:21:40
561
原创 设计模式Before-after之组合模式
before.cxx#include #include class Element {public: Element(int value): value(value) {}; void remove(void) { std::cout value << " has been removed." << std::endl; }private: int value;};
2014-03-15 00:35:10
595
原创 虚拟内存页号 to 物理内存页号
虚拟内存地址 = (虚拟内存页号,内存页内偏移)物理内存地址 = (物理内存页号,内存页内偏移)if 查快表,虚拟内存页在TLB中 thencase 1:虚拟内存地址 to 物理内存地址;else // 查快表,虚拟内存页不在TLB中case 2:if 查内表,虚拟内存页有对应的物理内存页 thencase 3
2014-03-14 23:13:35
2728
原创 L1缓存命中
typedef struct { uint24_t tag; unsigned char content[64];} cache_line_t;typedef struct { cache_line_t lines[8];} cache_set_t;typedef struct { cache_set_t sets[64];} l1_cache_t;typedef str
2014-03-14 20:33:59
644
原创 操作数的寻址方式
操作数:指令中进行数字运算的量,值。 立即寻址:操作数被包含在指令中。例:mov ax, 0 寄存器寻址:存储操作数的寄存器被包含在指令中。例:mov ax, bx 直接寻址:存储操作数的内存的地址被包含在指令中。例:mov ax, [1234H] 寄存器间接寻址:存储存储操作数的内存’的地址的寄存器被包含在指令中。例:movax, [bx] 寄存器相对寻址
2014-03-13 19:15:44
991
原创 设计模式Before-after之桥接模式
before.cxx#include class BlackCircle {public: void what(void) { std::cout << "a black circle." << std::endl; }};class BlackSquare {public: void what(void) { std::cout << "a black squar
2014-03-12 23:39:50
491
原创 设计模式Before-after之适配器模式
before.cxx#include class Dog {public: void runAway(void) { std::cout << "HELP!!! Dog-god bless me!" << std::endl; }};class DogHunter {public: void hunt(Dog &dog) { dog.runAway(); }};
2014-03-12 20:10:53
526
原创 设计模式Before-after之原型模式
before.cxx#include class Factorial {public: Factorial(unsigned int n) { double value = 1; for (unsigned int k = 2; k < n; ++k) { value *= k; } this->value = value; } void displayVal
2014-03-12 13:21:39
1047
原创 设计模式Before-after之建造者模式
before.cxx#include #include class Shape {public: void setColor(const std::string &colorName) { this->colorName = colorName; } void setKind(const std::string &kindName) { this->kindName =
2014-03-10 23:50:25
550
原创 设计模式Before-after之抽象工厂模式
before.cxx#include #include class BlackCircle {public: void sayHello(void) { std::cout << "Hello, I'm a black circle." << std::endl; }};class BlackSquare {public: void sayGoodbye(void
2014-03-10 16:38:38
656
原创 设计模式Before-after之工厂方法模式
before.cxx#include #include class Apple {public: void sayHello(void) { std::cout << "Hello, I'm a apple." << std::endl; }};class Banana {public: void sayHello(void) { std::cout << "He
2014-03-10 15:49:29
598
原创 设计模式Before-after之简单工厂模式
before.cxx#include #include class Apple {public: void sayHello(void) { std::cout << "Hello, I'm a apple." << std::endl; }};class Banana {public: void sayHello(void) { std::cout << "He
2014-03-10 13:14:50
814
原创 浮点数格式
『单精度浮点数』(高位->低位)符 号:1位指数部分:8位小数部分:23位整数部分:设定恒为1,因此不需要位总 计:32位表 示:1.小数部分 * 2^(指数部分 - 127) = (2^23 + 小数部分) * 2^(指数部分 - 150)『双精度浮点数』(高位->低位)符 号:1位指数部分:11位小数部分:52位整数部分:设
2014-03-08 17:08:08
972
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人