Codechange: be more type-specific about types in NPFs queue (#11192)

This commit is contained in:
Patric Stout
2023-08-12 20:18:22 +02:00
committed by GitHub
parent 299570b2c1
commit 9624017fc2
4 changed files with 33 additions and 30 deletions

View File

@@ -10,6 +10,9 @@
#ifndef QUEUE_H
#define QUEUE_H
#include "../../tile_type.h"
#include "../../track_type.h"
//#define HASH_STATS
@@ -58,8 +61,8 @@ struct BinaryHeap {
* Hash
*/
struct HashNode {
uint key1;
uint key2;
TileIndex tile;
Trackdir dir;
void *value;
HashNode *next;
};
@@ -67,7 +70,7 @@ struct HashNode {
* Generates a hash code from the given key pair. You should make sure that
* the resulting range is clearly defined.
*/
typedef uint Hash_HashProc(uint key1, uint key2);
typedef uint Hash_HashProc(TileIndex tile, Trackdir dir);
struct Hash {
/* The hash function used */
Hash_HashProc *hash;
@@ -83,10 +86,10 @@ struct Hash {
void Init(Hash_HashProc *hash, uint num_buckets);
void *Get(uint key1, uint key2) const;
void *Set(uint key1, uint key2, void *value);
void *Get(TileIndex tile, Trackdir dir) const;
void *Set(TileIndex tile, Trackdir dir, void *value);
void *DeleteValue(uint key1, uint key2);
void *DeleteValue(TileIndex tile, Trackdir dir);
void Clear(bool free_values);
void Delete(bool free_values);
@@ -103,7 +106,7 @@ protected:
#ifdef HASH_STATS
void PrintStatistics() const;
#endif
HashNode *FindNode(uint key1, uint key2, HashNode** prev_out) const;
HashNode *FindNode(TileIndex tile, Trackdir dir, HashNode** prev_out) const;
};
#endif /* QUEUE_H */