summaryrefslogtreecommitdiff
path: root/qmake/include/qmap.h
Unidiff
Diffstat (limited to 'qmake/include/qmap.h') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/include/qmap.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/qmake/include/qmap.h b/qmake/include/qmap.h
index 269bd6b..4bc0a2f 100644
--- a/qmake/include/qmap.h
+++ b/qmake/include/qmap.h
@@ -691,193 +691,197 @@ public:
691 return sh->node_count == 0; 691 return sh->node_count == 0;
692 } 692 }
693 QPair<iterator,bool> insert( const value_type& x ); 693 QPair<iterator,bool> insert( const value_type& x );
694 694
695 void erase( iterator it ) 695 void erase( iterator it )
696 { 696 {
697 detach(); 697 detach();
698 sh->remove( it ); 698 sh->remove( it );
699 } 699 }
700 void erase( const key_type& k ); 700 void erase( const key_type& k );
701 size_type count( const key_type& k ) const; 701 size_type count( const key_type& k ) const;
702 T& operator[] ( const Key& k ); 702 T& operator[] ( const Key& k );
703 void clear(); 703 void clear();
704 704
705 iterator find ( const Key& k ) 705 iterator find ( const Key& k )
706 { 706 {
707 detach(); 707 detach();
708 return iterator( sh->find( k ).node ); 708 return iterator( sh->find( k ).node );
709 } 709 }
710 const_iterator find ( const Key& k ) const {return sh->find( k ); } 710 const_iterator find ( const Key& k ) const {return sh->find( k ); }
711 711
712 const T& operator[] ( const Key& k ) const 712 const T& operator[] ( const Key& k ) const
713 { QT_CHECK_INVALID_MAP_ELEMENT; return sh->find( k ).data(); } 713 { QT_CHECK_INVALID_MAP_ELEMENT; return sh->find( k ).data(); }
714 bool contains ( const Key& k ) const 714 bool contains ( const Key& k ) const
715 { return find( k ) != end(); } 715 { return find( k ) != end(); }
716 //{ return sh->find( k ) != ((const Priv*)sh)->end(); } 716 //{ return sh->find( k ) != ((const Priv*)sh)->end(); }
717 717
718 size_type count() const { return sh->node_count; } 718 size_type count() const { return sh->node_count; }
719 719
720 QValueList<Key> keys() const { 720 QValueList<Key> keys() const {
721 QValueList<Key> r; 721 QValueList<Key> r;
722 for (const_iterator i=begin(); i!=end(); ++i) 722 for (const_iterator i=begin(); i!=end(); ++i)
723 r.append(i.key()); 723 r.append(i.key());
724 return r; 724 return r;
725 } 725 }
726 726
727 QValueList<T> values() const { 727 QValueList<T> values() const {
728 QValueList<T> r; 728 QValueList<T> r;
729 for (const_iterator i=begin(); i!=end(); ++i) 729 for (const_iterator i=begin(); i!=end(); ++i)
730 r.append(*i); 730 r.append(*i);
731 return r; 731 return r;
732 } 732 }
733 733
734 bool isEmpty() const { return sh->node_count == 0; } 734 bool isEmpty() const { return sh->node_count == 0; }
735 735
736 iterator insert( const Key& key, const T& value, bool overwrite = TRUE ); 736 iterator insert( const Key& key, const T& value, bool overwrite = TRUE );
737 void remove( iterator it ) { detach(); sh->remove( it ); } 737 void remove( iterator it ) { detach(); sh->remove( it ); }
738 void remove( const Key& k ); 738 void remove( const Key& k );
739 739
740#if defined(Q_FULL_TEMPLATE_INSTANTIATION) 740#if defined(Q_FULL_TEMPLATE_INSTANTIATION)
741 bool operator==( const QMap<Key,T>& ) const { return FALSE; } 741 bool operator==( const QMap<Key,T>& ) const { return FALSE; }
742#ifndef QT_NO_STL 742#ifndef QT_NO_STL
743 bool operator==( const Q_TYPENAME std::map<Key,T>& ) const { return FALSE; } 743 bool operator==( const Q_TYPENAME std::map<Key,T>& ) const { return FALSE; }
744#endif 744#endif
745#endif 745#endif
746 746
747protected: 747protected:
748 /** 748 /**
749 * Helpers 749 * Helpers
750 */ 750 */
751 void detach() { if ( sh->count > 1 ) detachInternal(); } 751 void detach() { if ( sh->count > 1 ) detachInternal(); }
752 752
753 Priv* sh; 753 Priv* sh;
754private: 754private:
755 void detachInternal(); 755 void detachInternal();
756 756
757 friend class QDeepCopy< QMap<Key,T> >; 757 friend class QDeepCopy< QMap<Key,T> >;
758}; 758};
759 759
760template<class Key, class T> 760template<class Key, class T>
761Q_INLINE_TEMPLATES QMap<Key,T>& QMap<Key,T>::operator= ( const QMap<Key,T>& m ) 761Q_INLINE_TEMPLATES QMap<Key,T>& QMap<Key,T>::operator= ( const QMap<Key,T>& m )
762{ 762{
763 m.sh->ref(); 763 m.sh->ref();
764 if ( sh->deref() ) 764 if ( sh->deref() )
765 delete sh; 765 delete sh;
766 sh = m.sh; 766 sh = m.sh;
767 return *this; 767 return *this;
768} 768}
769 769
770template<class Key, class T> 770template<class Key, class T>
771Q_INLINE_TEMPLATES Q_TYPENAME QMap<Key,T>::insert_pair QMap<Key,T>::insert( const Q_TYPENAME QMap<Key,T>::value_type& x ) 771Q_INLINE_TEMPLATES Q_TYPENAME QMap<Key,T>::insert_pair QMap<Key,T>::insert( const Q_TYPENAME QMap<Key,T>::value_type& x )
772{ 772{
773 detach(); 773 detach();
774 size_type n = size(); 774 size_type n = size();
775 iterator it = sh->insertSingle( x.first ); 775 iterator it = sh->insertSingle( x.first );
776 bool inserted = FALSE; 776 bool inserted = FALSE;
777 if ( n < size() ) { 777 if ( n < size() ) {
778 inserted = TRUE; 778 inserted = TRUE;
779 it.data() = x.second; 779 it.data() = x.second;
780 } 780 }
781 return QPair<iterator,bool>( it, inserted ); 781 return QPair<iterator,bool>( it, inserted );
782} 782}
783 783
784template<class Key, class T> 784template<class Key, class T>
785Q_INLINE_TEMPLATES void QMap<Key,T>::erase( const Key& k ) 785Q_INLINE_TEMPLATES void QMap<Key,T>::erase( const Key& k )
786{ 786{
787 detach(); 787 detach();
788 iterator it( sh->find( k ).node ); 788 iterator it( sh->find( k ).node );
789 if ( it != end() ) 789 if ( it != end() )
790 sh->remove( it ); 790 sh->remove( it );
791} 791}
792 792
793template<class Key, class T> 793template<class Key, class T>
794Q_INLINE_TEMPLATES Q_TYPENAME QMap<Key,T>::size_type QMap<Key,T>::count( const Key& k ) const 794Q_INLINE_TEMPLATES Q_TYPENAME QMap<Key,T>::size_type QMap<Key,T>::count( const Key& k ) const
795{ 795{
796 const_iterator it( sh->find( k ).node ); 796 const_iterator it( sh->find( k ).node );
797 if ( it != end() ) { 797 if ( it != end() ) {
798 size_type c = 0; 798 size_type c = 0;
799 while ( it != end() ) { 799 while ( it != end() ) {
800 ++it; 800 ++it;
801 ++c; 801 ++c;
802 } 802 }
803 return c; 803 return c;
804 } 804 }
805 return 0; 805 return 0;
806} 806}
807 807
808template<class Key, class T> 808template<class Key, class T>
809Q_INLINE_TEMPLATES T& QMap<Key,T>::operator[] ( const Key& k ) 809Q_INLINE_TEMPLATES T& QMap<Key,T>::operator[] ( const Key& k )
810{ 810{
811 detach(); 811 detach();
812 QMapNode<Key,T>* p = sh->find( k ).node; 812 QMapNode<Key,T>* p = sh->find( k ).node;
813 if ( p != sh->end().node ) 813 if ( p != sh->end().node )
814 return p->data; 814 return p->data;
815 return insert( k, T() ).data(); 815 return insert( k, T() ).data();
816} 816}
817 817
818template<class Key, class T> 818template<class Key, class T>
819Q_INLINE_TEMPLATES void QMap<Key,T>::clear() 819Q_INLINE_TEMPLATES void QMap<Key,T>::clear()
820{ 820{
821 if ( sh->count == 1 ) 821 if ( sh->count == 1 )
822 sh->clear(); 822 sh->clear();
823 else { 823 else {
824 sh->deref(); 824 sh->deref();
825 sh = new QMapPrivate<Key,T>; 825 sh = new QMapPrivate<Key,T>;
826 } 826 }
827} 827}
828 828
829template<class Key, class T> 829template<class Key, class T>
830Q_INLINE_TEMPLATES Q_TYPENAME QMap<Key,T>::iterator QMap<Key,T>::insert( const Key& key, const T& value, bool overwrite ) 830Q_INLINE_TEMPLATES Q_TYPENAME QMap<Key,T>::iterator QMap<Key,T>::insert( const Key& key, const T& value, bool overwrite )
831{ 831{
832 detach(); 832 detach();
833 size_type n = size(); 833 size_type n = size();
834 iterator it = sh->insertSingle( key ); 834 iterator it = sh->insertSingle( key );
835 if ( overwrite || n < size() ) 835 if ( overwrite || n < size() )
836 it.data() = value; 836 it.data() = value;
837 return it; 837 return it;
838} 838}
839 839
840template<class Key, class T> 840template<class Key, class T>
841Q_INLINE_TEMPLATES void QMap<Key,T>::remove( const Key& k ) 841Q_INLINE_TEMPLATES void QMap<Key,T>::remove( const Key& k )
842{ 842{
843 detach(); 843 detach();
844 iterator it( sh->find( k ).node ); 844 iterator it( sh->find( k ).node );
845 if ( it != end() ) 845 if ( it != end() )
846 sh->remove( it ); 846 sh->remove( it );
847} 847}
848 848
849template<class Key, class T> 849template<class Key, class T>
850Q_INLINE_TEMPLATES void QMap<Key,T>::detachInternal() 850Q_INLINE_TEMPLATES void QMap<Key,T>::detachInternal()
851{ 851{
852 sh->deref(); sh = new QMapPrivate<Key,T>( sh ); 852 sh->deref(); sh = new QMapPrivate<Key,T>( sh );
853} 853}
854 854
855 855
856#ifndef QT_NO_DATASTREAM 856#ifndef QT_NO_DATASTREAM
857template<class Key, class T> 857template<class Key, class T>
858Q_INLINE_TEMPLATES QDataStream& operator>>( QDataStream& s, QMap<Key,T>& m ) { 858Q_INLINE_TEMPLATES QDataStream& operator>>( QDataStream& s, QMap<Key,T>& m ) {
859 m.clear(); 859 m.clear();
860 Q_UINT32 c; 860 Q_UINT32 c;
861 s >> c; 861 s >> c;
862 for( Q_UINT32 i = 0; i < c; ++i ) { 862 for( Q_UINT32 i = 0; i < c; ++i ) {
863 Key k; T t; 863 Key k; T t;
864 s >> k >> t; 864 s >> k >> t;
865 m.insert( k, t ); 865 m.insert( k, t );
866 if ( s.atEnd() ) 866 if ( s.atEnd() )
867 break; 867 break;
868 } 868 }
869 return s; 869 return s;
870} 870}
871 871
872 872
873template<class Key, class T> 873template<class Key, class T>
874Q_INLINE_TEMPLATES QDataStream& operator<<( QDataStream& s, const QMap<Key,T>& m ) { 874Q_INLINE_TEMPLATES QDataStream& operator<<( QDataStream& s, const QMap<Key,T>& m ) {
875 s << (Q_UINT32)m.size(); 875 s << (Q_UINT32)m.size();
876 QMapConstIterator<Key,T> it = m.begin(); 876 QMapConstIterator<Key,T> it = m.begin();
877 for( ; it != m.end(); ++it ) 877 for( ; it != m.end(); ++it )
878 s << it.key() << it.data(); 878 s << it.key() << it.data();
879 return s; 879 return s;
880} 880}
881#endif 881#endif
882 882
883#ifdef QT_QWINEXPORT
884#define Q_DEFINED_QMAP
885#include "qwinexport.h"
886#endif /* QT_QWINEXPORT */
883#endif // QMAP_H 887#endif // QMAP_H