1 // Copyright 2018 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #pragma once 6 7 #include <fbl/intrusive_hash_table.h> 8 9 namespace display { 10 11 // Helper for allowing structs which are identified by unique ids to be put in a hashmap. 12 template <typename T> class IdMappable : public fbl::SinglyLinkedListable<T> { 13 public: 14 uint64_t id; 15 GetHash(uint64_t id)16 static size_t GetHash(uint64_t id) { return id; } 17 GetKey()18 uint64_t GetKey() const { return id; } 19 20 using Map = fbl::HashTable<uint64_t, T>; 21 }; 22 23 } // namespace display 24