NAMD
Classes | Typedefs | Variables
TupleString.h File Reference
#include <string>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include "xxh3.h"

Go to the source code of this file.

Classes

struct  MStringStrider
 
struct  TupleStrider< NumStrings >
 
class  MultiString< NumStrings >
 
class  TupleString< NumStrings >
 
struct  TupleStringHash< NumStrings >
 
class  TwoLevelParam< NumStrings, ParamValue >
 

Typedefs

typedef TupleString< 1 > TupleString1
 
typedef TupleString< 2 > TupleString2
 
typedef TupleString< 3 > TupleString3
 
typedef TupleString< 4 > TupleString4
 
typedef TupleString< 8 > TupleString8
 

Variables

static const short ParamNameMaxLen =11
 

Typedef Documentation

◆ TupleString1

Definition at line 255 of file TupleString.h.

◆ TupleString2

Definition at line 256 of file TupleString.h.

◆ TupleString3

Definition at line 257 of file TupleString.h.

◆ TupleString4

Definition at line 258 of file TupleString.h.

◆ TupleString8

Definition at line 259 of file TupleString.h.

Variable Documentation

◆ ParamNameMaxLen

const short ParamNameMaxLen =11
static

Utility class to store the tuple of strings in a single contiguous buffer. We keep null seperators between each part of the buffer. Everything has a fixed size .

Provides the following benefits:

  1. Null terminated char pointers to each individual member of the tuple. In compliance with c_string behavior potentially allowing easy casting to std::string.
  2. Treat the entire tuple as one buffer for key creation, equivalence testing, serialization, or any memory operation.
  3. Avoids false match confusion between a tuples that would appear to be the same if concatenated, e.g., A BA != AB A,
  4. We use memcmp on the buffer instead of multiple strncmp
  5. Specific classes are provided for the 2,3,4 tuple cases.

Slight downsides:

  1. We could technically save space by only allocating to the strlen of input, but it isn't a lot of space and it would mean a bunch of conditional logic. Having everything fixed length means we avoid branches, and we can use fixed length arrays under the hood, thereby giving the compiler as much information as we can for it to optimize.
  2. In order to avoid virtual function overhead, weird issues with having inheritance on things with different sizes, and minimal initialization overheads, we embrace the composition of templates with a slightly weird looking TwoLevelParam< NumTuple, YourParamStruct>

Definition at line 58 of file TupleString.h.

Referenced by MultiString< NumStrings >::getTupleMaxLen().