-
Notifications
You must be signed in to change notification settings - Fork 30
/
sbhash.h
64 lines (49 loc) · 1.79 KB
/
sbhash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* -*- Mode: C++ ; indent-tabs-mode: nil ; c-file-style: "stroustrup" -*-
Project: samblaster
Fast mark duplicates in read-ID grouped SAM file.
Also, optionally pull discordants, splitters, and/or unmappend/clipped reads.
Author: Greg Faust ([email protected])
Date: October 2013
File: sbhash.h header file for our hash table.
License Information:
Copyright 2013-2016 Gregory G. Faust
Licensed under the MIT license (the "License");
You may not use this file except in compliance with the License.
You may obtain a copy of the License at http://opensource.org/licenses/MIT
*/
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
// Rename common integer types.
// I like having these shorter name.
typedef uint64_t UINT64;
typedef uint32_t UINT32;
///////////////////////////////////////////////////////////////////////////////
// Hash Table Collision Nodes
///////////////////////////////////////////////////////////////////////////////
// This controls the number of data values to store in each hadnNode.
#define HASHNODE_PAYLOAD_SIZE 3
typedef struct hashNode hashNode_t;
struct hashNode
{
hashNode_t * next;
UINT64 values[HASHNODE_PAYLOAD_SIZE];
};
hashNode_t * getHashNode();
void disposeHashNode(hashNode_t * node);
///////////////////////////////////////////////////////////////////////////////
// Hash Table
///////////////////////////////////////////////////////////////////////////////
typedef struct hashTable hashTable_t;
struct hashTable
{
UINT64 * table;
UINT32 size;
UINT32 entries;
~hashTable();
};
hashTable_t * makeHashTable();
void deleteHashTable(hashTable_t * ht);
bool hashTableInsert(hashTable_t * ht, UINT64 value);
void hashTableInit(hashTable_t * ht, int size=0);
void freeHashTableNodes();