yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1#include "slang-string-slice-index-map.h" 2 3namespace Slang 4{ 5 6// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! StringSliceIndexMap !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 7 8StringSliceIndexMap ::CountIndex StringSliceIndexMap ::add ( 9const UnownedStringSlice & key , 10Index valueIndex ) 11{ 12StringSlicePool ::Handle handle ; 13m_pool .findOrAdd (key ,handle ); 14const CountIndex countIndex = StringSlicePool ::asIndex (handle ); 15if (countIndex >=m_indexMap .getCount ()) 16 { 17SLANG_ASSERT (countIndex == m_indexMap .getCount ()); 18m_indexMap .add (valueIndex ); 19 } 20else 21 { 22m_indexMap [countIndex ]= valueIndex ; 23 } 24return countIndex ; 25} 26 27StringSliceIndexMap ::CountIndex StringSliceIndexMap ::findOrAdd ( 28const UnownedStringSlice & key , 29Index defaultValueIndex ) 30{ 31StringSlicePool ::Handle handle ; 32m_pool .findOrAdd (key ,handle ); 33const CountIndex countIndex = StringSlicePool ::asIndex (handle ); 34if (countIndex >=m_indexMap .getCount ()) 35 { 36SLANG_ASSERT (countIndex == m_indexMap .getCount ()); 37m_indexMap .add (defaultValueIndex ); 38 } 39return countIndex ; 40} 41 42void StringSliceIndexMap ::clear () 43{ 44m_pool .clear (); 45m_indexMap .clear (); 46} 47 48}// namespace Slang