Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

hashset-cpp-v10

1.0.0 • Public • Published

fork

This is a fork to make hashset-cpp work with with node v10

hashset-cpp

Implements a simple HashSet for strings in environments where you don't have the std lib available. You should probably not be using this. Instead consider using hash_set which is a more generic implementation with templates. This is only useful for very specific use cases having specific memory layout requirements.

Setup

npm install --save hashset-cpp

Sample

#include <iostream>
#include "HashSet.h"
#include "test/exampleData.h"
 
using std::cout;
using std::endl;
 
int main(int argc, char **argv) {
  HashSet<ExampleData> set(256);
  set.add(ExampleData("test"));
 
  // Prints true 
  cout << "test exists: " << (set.exists(ExampleData("test"))
      ? "true" : "false") << endl;
  // Prints false 
  cout << "test2 exists: " << (set.exists(ExampleData("test2"))
      ? "true" : "false") << endl;
 
  uint32_t len;
  char * buffer = set.serialize(&len);
  HashSet<ExampleData> set2(0);
  set2.deserialize(buffer, len);
  // Prints true 
  cout << "test exists: " << (set2.exists(ExampleData("test"))
      ? "true" : "false") << endl;
  // Prints false 
  cout << "test2 exists: " << (set2.exists(ExampleData("test2"))
      ? "true" : "false") << endl;
 
  delete[] buffer;
  return 0;
}

Build everything in release

make

Running sample

make sample

Running tests

make test

Clearing build files

make clean

Linting

npm run lint

Keywords

none

Install

npm i hashset-cpp-v10

DownloadsWeekly Downloads

0

Version

1.0.0

License

MPL-2.0

Unpacked Size

57.8 kB

Total Files

29

Last publish

Collaborators

  • avatar