Changeset 384


Ignore:
Timestamp:
06/04/15 18:46:42 (10 years ago)
Author:
epyon
Message:
  • minimum capacity increase for array
  • fixed limits
  • hash cleanup in rtti
Location:
trunk/nv/stl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/stl/array.hh

    r383 r384  
    3535                static SizeType get( SizeType requested, SizeType capacity, SizeType max_size )
    3636                {
     37                        SizeType minimum = nv::min<SizeType>( capacity, 4 );
    3738                        SizeType remaining = max_size - capacity;
    3839                        if ( remaining < requested ) return 0;
    3940                        SizeType additional = nv::max( requested, capacity );
    40                         return ( remaining < additional ? max_size : capacity + additional );
     41                        return nv::max( minimum, remaining < additional ? max_size : capacity + additional );
    4142                }
    4243        };
     
    600601        using vector = array_base_t < growing_container_allocator< growable_dynamic_storage< T > > >;
    601602
    602 //      template < typename T, typename ContainerAllocator >
    603 //      class vector_base
    604 //      {
    605 //      public:
    606 //              typedef T         value_type;
    607 //              typedef size_t    size_type;
    608 //              typedef ptrdiff_t difference_type;
    609 //              typedef T*        pointer;
    610 //              typedef const T*  const_pointer;
    611 //              typedef T*        iterator;
    612 //              typedef const T*  const_iterator;
    613 //              typedef T&        reference;
    614 //              typedef const T&  const_reference;
    615 //
    616 //      protected:
    617 //              ContainerAllocator m_storage;
    618 //      };
    619 
    620 //      template< typename T, size_t N >
    621 //      class static_vector : public detail::pointer_iterators < static_vector< T, N >, T, false >
    622 //      {
    623 //      public:
    624 //              typedef T         value_type;
    625 //              typedef size_t    size_type;
    626 //              typedef ptrdiff_t difference_type;
    627 //              typedef T*        pointer;
    628 //              typedef const T*  const_pointer;
    629 //              typedef T*        iterator;
    630 //              typedef const T*  const_iterator;
    631 //              typedef T&        reference;
    632 //              typedef const T&  const_reference;
    633 //              typedef nv::reverse_iterator<iterator>       reverse_iterator;
    634 //              typedef nv::reverse_iterator<const_iterator> const_reverse_iterator;
    635 //
    636 //              static_vector() : m_size(0) {}
    637 //
    638 //              inline const_pointer data() const { return m_data; }
    639 //              inline pointer data() { return m_data; }
    640 //              inline size_type size() const { return m_size; }
    641 //              inline bool empty() const { return !m_size; }
    642 //              inline size_type   raw_size() const { return N * sizeof( T ); }
    643 //              inline const char* raw_data() const { return (const char*)m_data; }
    644 //              inline char*       raw_data() { return (char*)m_data; }
    645 //
    646 //              inline reference       front() { NV_ASSERT( !empty(), "front() called on empty data!" );  return m_data[0]; }
    647 //              inline const_reference front() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[0]; }
    648 //              inline reference       back() { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[m_size - 1]; }
    649 //              inline const_reference back() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[m_size - 1]; }
    650 //      protected:
    651 //              value_type m_data[N];
    652 //              size_type  m_size;
    653 //      };
    654 
    655603}
    656604
  • trunk/nv/stl/limits.hh

    r382 r384  
    1616#include <nv/core/common.hh>
    1717
     18#if NV_COMPILER == NV_MSVC
     19#ifdef min
     20#undef min
     21#endif
     22#ifdef max
     23#undef max
     24#endif
     25#endif
     26
    1827namespace nv
    1928{
     
    2231                static constexpr unsigned char uc_min = 0;
    2332                static constexpr unsigned char uc_max = 255;
    24                 static constexpr unsigned char uc_bit = sizeof( unsigned char ) * 8;
     33                static constexpr int uc_bit = sizeof( unsigned char ) * 8;
    2534                static constexpr signed char sc_min = -128;
    2635                static constexpr signed char sc_max = 127;
    27                 static constexpr signed char sc_bit = sizeof( signed char ) * 8;
     36                static constexpr int sc_bit = sizeof( signed char ) * 8;
    2837                static constexpr char c_min = ( char( 0 ) < char( -1 ) ? 0 : -128 );
    2938                static constexpr char c_max = ( char( 0 ) < char( -1 ) ? 255 : 127 );
    30                 static constexpr char c_bit = sizeof( char ) * 8;
     39                static constexpr int c_bit = sizeof( char ) * 8;
    3140                static constexpr unsigned short us_min = 0;
    3241                static constexpr unsigned short us_max = 65535;
    33                 static constexpr unsigned short us_bit = sizeof( unsigned short ) * 8;
     42                static constexpr int us_bit = sizeof( unsigned short ) * 8;
    3443                static constexpr signed short ss_min = -32768;
    3544                static constexpr signed short ss_max = 32767;
    36                 static constexpr signed short ss_bit = sizeof( signed short ) * 8;
    37                 static constexpr unsigned int ui_min = 0;
    38                 static constexpr unsigned int ui_max = 4294967295;
    39                 static constexpr unsigned int ui_bit = sizeof( unsigned int ) * 8;
    40                 static constexpr signed int si_min = -2147483648;
     45                static constexpr int ss_bit = sizeof( signed short ) * 8;
     46                static constexpr unsigned int ui_min = 0UL;
     47                static constexpr unsigned int ui_max = 4294967295UL;
     48                static constexpr int ui_bit = sizeof( unsigned int ) * 8;
     49                static constexpr signed int si_min = ( -2147483647 - 1 );
    4150                static constexpr signed int si_max = 2147483647;
    42                 static constexpr signed int si_bit = sizeof( signed int ) * 8;
    43                 static constexpr unsigned long ul_min = 0;
    44                 static constexpr unsigned long ul_max = 4294967295;
    45                 static constexpr unsigned long ul_bit = sizeof( unsigned long ) * 8;
    46                 static constexpr signed long sl_min = -2147483648;
    47                 static constexpr signed long sl_max = 2147483647;
    48                 static constexpr signed long sl_bit = sizeof( signed long ) * 8;
    49                 static constexpr unsigned long long ull_min = 0;
    50                 static constexpr unsigned long long ull_max = 18446744073709551615;
    51                 static constexpr unsigned long long ull_bit = sizeof( unsigned long long ) * 8;
    52                 static constexpr signed long long sll_min = -9223372036854775808;
    53                 static constexpr signed long long sll_max = 9223372036854775807;
    54                 static constexpr signed long long sll_bit = sizeof( signed long long ) * 8;
     51                static constexpr int si_bit = sizeof( signed int ) * 8;
     52                static constexpr unsigned long ul_min = 0UL;
     53                static constexpr unsigned long ul_max = 4294967295UL;
     54                static constexpr int ul_bit = sizeof( unsigned long ) * 8;
     55                static constexpr signed long sl_min = ( -2147483647L -1 );
     56                static constexpr signed long sl_max = 2147483647L;
     57                static constexpr int sl_bit = sizeof( signed long ) * 8;
     58                static constexpr unsigned long long ull_min = 0ULL;
     59                static constexpr unsigned long long ull_max = 18446744073709551615ULL;
     60                static constexpr int ull_bit = sizeof( unsigned long long ) * 8;
     61                static constexpr signed long long sll_min = ( -9223372036854775807LL - 1 );
     62                static constexpr signed long long sll_max = 9223372036854775807LL;
     63                static constexpr int sll_bit = sizeof( signed long long ) * 8;
    5564
    5665                static constexpr int f_dig        = 6;
  • trunk/nv/stl/rtti_support.hh

    r382 r384  
    6161        }
    6262
    63         // run-time hash
    64         inline uint64 rtti_hash( const char* str )
    65         {
    66                 uint64 hash = detail::rtti_hash_basis;
    67                 while ( *str != 0 )
    68                 {
    69                         hash ^= (uint64)str[0];
    70                         hash *= detail::rtti_hash_prime;
    71                         ++str;
    72                 }
    73                 return hash;
    74         }
    75 
    7663        template < typename T >
    7764        struct rtti_type_hash
Note: See TracChangeset for help on using the changeset viewer.