Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upmore C like C++ #3
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
brendano
Feb 7, 2014
Owner
cool! if you can submit this as a pull request i'll merge. (it would be nice to confirm it gets the same answer as the other implementations...)
|
cool! if you can submit this as a pull request i'll merge. (it would be nice to confirm it gets the same answer as the other implementations...) |
brendano
closed this
Feb 7, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tedu commentedFeb 6, 2014
Here is a more C like C++ implementation. :)
It's a fair bit faster because std::string is slow. Still using hash_map because it's convenient.
include <stdio.h>
include
using namespace std;
include <ext/hash_map>
using namespace __gnu_cxx;
int
readline(FILE _fp, char *_item, char *_feat, char *_val)
{
char *p;
static char buf[1024];
}
struct eqstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) == 0;
}
};
int main(int argc, const char argv)
{
hash_map<const char, int, hash<const char>, eqstr> imap;
hash_map<const char*, int, hash<const char*>, eqstr> jmap;
hash_map<const char*, int, hash<const char*>, eqstr> I;
int J=0;
FILE *vocab = fopen("vocab", "w");
typeof(imap.end()) imapend = imap.end();
typeof(jmap.end()) jmapend = jmap.end();
for (int file_i=1; file_i<argc; file_i++) {
printf("%s\n",argv[file_i]);
}
return 0;
}