This file contains hidden or 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
| // | |
| // bit_vector.h | |
| // | |
| // Created by identifer on 5/12/14. | |
| // Copyright (c) 2014 identifer. All rights reserved. | |
| // | |
| #ifndef BIT_VECTOR_H | |
| #define BIT_VECTOR_H |
This file contains hidden or 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 <stdint.h> | |
| #include <stdlib.h> | |
| // assert(RAND_MAX >= 0x7fff) | |
| float | |
| random_0_to_1() { | |
| union { | |
| uint32_t d; | |
| float f; | |
| } u; |
This file contains hidden or 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
| // from http://mindhacks.cn/2012/08/27/modern-cpp-practices/ | |
| #ifndef SCOPE_GUARD_H | |
| #define SCOPE_GUARD_H | |
| #include <functional> | |
| class scope_guard { | |
| private: | |
| scope_guard(const scope_guard&); |
This file contains hidden or 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 "date.h" |
This file contains hidden or 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 <vector> | |
| typedef std::vector<int> int_vec; | |
| // the size of ivec1 is less than or equal to the size of ivec2 | |
| static bool is_prefix_impl(const int_vec& ivec1, const int_vec& ivec2) | |
| { | |
| auto it1 = ivec1.begin(); | |
| auto it2 = ivec2.begin(); |
This file contains hidden or 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 <string> | |
| int main(int arc, char* argv[]) | |
| { | |
| int max_count = 0; | |
| std::string max_count_word; | |
| int count = 0; | |
| std::string prev_word; |