Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #515 from gsomix/CSet
CSet and CMap
- Loading branch information
Showing
6 changed files
with
512 additions
and
36 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <shogun/lib/Map.h> | ||
#include <shogun/io/SGIO.h> | ||
#include <shogun/base/init.h> | ||
#include <shogun/lib/common.h> | ||
|
||
using namespace shogun; | ||
|
||
#define SIZE 6 | ||
|
||
void print_message(FILE* target, const char* str) | ||
{ | ||
fprintf(target, "%s", str); | ||
} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
init_shogun(&print_message, &print_message, &print_message); | ||
const char* v[SIZE] = {"Russia", "England", "Germany", "USA", "France", "Spain"}; | ||
|
||
CMap<int32_t, const char*>* map = new CMap<int32_t, const char*>(SIZE/2, SIZE/2); | ||
|
||
for (int i=0; i<SIZE; i++) | ||
map->add(i, v[i]); | ||
|
||
map->remove(0); | ||
|
||
//SG_SPRINT("Num of elements: %d\n", map->get_num_elements()); | ||
for (int i=0; i<SIZE; i++) | ||
{ | ||
if (map->contains(i)); | ||
//SG_SPRINT("key %d contains in map with index %d and data=%s\n", | ||
// i, map->index_of(i), map->get_element(i)); | ||
} | ||
|
||
SG_UNREF(map); | ||
exit_shogun(); | ||
return 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <shogun/lib/Set.h> | ||
#include <shogun/io/SGIO.h> | ||
#include <shogun/base/init.h> | ||
#include <shogun/lib/common.h> | ||
|
||
using namespace shogun; | ||
|
||
#define SIZE 8 | ||
|
||
void print_message(FILE* target, const char* str) | ||
{ | ||
fprintf(target, "%s", str); | ||
} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
init_shogun(&print_message, &print_message, &print_message); | ||
double v[SIZE] = {0.0,0.1,0.2,0.2,0.3,0.4,0.5,0.5}; | ||
|
||
CSet<double>* set = new CSet<double>(SIZE/2, SIZE/2); | ||
|
||
for (int i=0; i<SIZE; i++) | ||
set->add(v[i]); | ||
|
||
set->remove(0.2); | ||
|
||
//SG_SPRINT("Num of elements: %d\n", set->get_num_elements()); | ||
for (int i=0; i<SIZE; i++) | ||
{ | ||
if (set->contains(v[i])); | ||
//SG_SPRINT("%lg contains in set with index %d\n", v[i], set->index_of(v[i])); | ||
} | ||
|
||
SG_UNREF(set); | ||
exit_shogun(); | ||
return 0; | ||
} |
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
Oops, something went wrong.