diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-29 14:49:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 14:49:26 +0800 |
| commit | f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch) | |
| tree | ea1d61342cd29368e19135000ec2948813096205 /source/core/slang-string-slice-index-map.h | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'source/core/slang-string-slice-index-map.h')
| -rw-r--r-- | source/core/slang-string-slice-index-map.h | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/source/core/slang-string-slice-index-map.h b/source/core/slang-string-slice-index-map.h index c57e0f570..b7c316c24 100644 --- a/source/core/slang-string-slice-index-map.h +++ b/source/core/slang-string-slice-index-map.h @@ -2,59 +2,61 @@ #define SLANG_CORE_STRING_SLICE_INDEX_MAP_H #include "slang-basic.h" - #include "slang-string-slice-pool.h" namespace Slang { -/* Maps an UnownedStringSlice to an index. All substrings are held internally in a StringSlicePool, and so -owned by the type. +/* Maps an UnownedStringSlice to an index. All substrings are held internally in a StringSlicePool, +and so owned by the type. */ class StringSliceIndexMap { public: - /// An index that identifies a key value pair. + /// An index that identifies a key value pair. typedef Index CountIndex; - /// Adds a key, value pair. Returns the CountIndex of the pair. - /// If there is already a value stored for the key it is replaced. + /// Adds a key, value pair. Returns the CountIndex of the pair. + /// If there is already a value stored for the key it is replaced. CountIndex add(const UnownedStringSlice& key, Index valueIndex); - /// Finds or adds the slice. If the slice is added the defaultValueIndex is set. - /// If not the index associated with the slice remains the same. - /// Returns the CountIndex where the key,value pair are stored + /// Finds or adds the slice. If the slice is added the defaultValueIndex is set. + /// If not the index associated with the slice remains the same. + /// Returns the CountIndex where the key,value pair are stored CountIndex findOrAdd(const UnownedStringSlice& key, Index defaultValueIndex); - /// Gets the index associated with the key. Returns -1 if there is no associated index. + /// Gets the index associated with the key. Returns -1 if there is no associated index. SLANG_FORCE_INLINE Index getValue(const UnownedStringSlice& key); - /// Get the amount of pairs in the map + /// Get the amount of pairs in the map Index getCount() const { return m_indexMap.getCount(); } - /// Get the slice and the index at the specified index + /// Get the slice and the index at the specified index SLANG_INLINE KeyValuePair<UnownedStringSlice, Index> getAt(CountIndex countIndex) const; - - /// Clear the contents of the map + + /// Clear the contents of the map void clear(); - /// Get the key at the specified index - UnownedStringSlice getKeyAt(CountIndex index) const { return m_pool.getSlice(StringSlicePool::Handle(index)); } - /// Get the value at the specified index + /// Get the key at the specified index + UnownedStringSlice getKeyAt(CountIndex index) const + { + return m_pool.getSlice(StringSlicePool::Handle(index)); + } + /// Get the value at the specified index Index& getValueAt(CountIndex index) { return m_indexMap[index]; } - /// Get the amount of key,value pairs + /// Get the amount of key,value pairs Index getCount() { return m_indexMap.getCount(); } - /// Ctor - StringSliceIndexMap() : - m_pool(StringSlicePool::Style::Empty) + /// Ctor + StringSliceIndexMap() + : m_pool(StringSlicePool::Style::Empty) { } protected: - StringSlicePool m_pool; ///< Pool holds the substrings - List<Index> m_indexMap; ///< Maps a pool index to the output index + StringSlicePool m_pool; ///< Pool holds the substrings + List<Index> m_indexMap; ///< Maps a pool index to the output index }; // --------------------------------------------------------------------------- @@ -73,6 +75,6 @@ KeyValuePair<UnownedStringSlice, Index> StringSliceIndexMap::getAt(CountIndex co return pair; } -} +} // namespace Slang #endif |
