1. gyulalaszlo
  2. mkz-foundation

Commits

gyulalaszlo  committed f53dae2

fixed inline declarations, added hash::size()

  • Participants
  • Parent commits 108975c
  • Branches master

Comments (0)

Files changed (1)

File hash_extension.h

View file
         /// Remove all elements from the hash
         template<typename T> void clear( Hash<T>& hsh );
 
+        /// Get the number of elements in hsh
+        template<typename T> uint32_t size( const Hash<T>& hsh );
+        
         /// Get a pointer from the hash or nullptr if no such ptr is there.
         /// This is a convinience function to get rid of casting when nullptr is planned to be
         /// returned as a default value.
-        template<typename T> T* get_ptr( Hash<T*>& hsh, uint64_t key );
+        template<typename T> T* get_ptr( const Hash<T*>& hsh, uint64_t key );
 
         /// Deallocate all pointed objects in the hash with allocator.deallocate()
         /// Useful for hashes containing allocated pointers.
             array::clear( hsh._hash );
         }
 
+        template<typename T> 
+        inline uint32_t size( const Hash<T*>& hsh )
+        {
+            return array::size( hsh._data );
+        }
 
-        template<typename T> T* get_ptr( Hash<T*>& hsh, uint64_t key )
+
+        template<typename T> 
+        inline T* get_ptr( const Hash<T*>& hsh, uint64_t key )
         {
             return hash::get( hsh, key, ( T* )nullptr );
         }
 
 
         template <typename KeyType, typename T>
-        void collect_from( Hash<T*>& hsh, T* start, T*  end, const uint32_t key_offset )
+        inline void collect_from( Hash<T*>& hsh, T* start, T*  end, const uint32_t key_offset )
         {
             for ( T* cursor = start; cursor != end; ++cursor )
             {
         }
 
         template <typename KeyType, typename T>
-        void collect_from( Hash<T*>& hsh, T* start, const int data_size, const uint32_t key_offset )
+        inline void collect_from( Hash<T*>& hsh, T* start, const int data_size, const uint32_t key_offset )
         {
             collect_from<KeyType>( hsh, start, start + data_size, key_offset );
         }
+
     }
 }