TagLib API Documentation
Public Member Functions | Protected Member Functions | List of all members
TagLib::Map< Key, T > Class Template Reference

A generic, implicitly shared map. More...

#include <tmap.h>

Inheritance diagram for TagLib::Map< Key, T >:
[legend]

Public Member Functions

 Map ()
 
 Map (const Map< Key, T > &m)
 
 Map (std::initializer_list< std::pair< const Key, T > > init)
 
 ~Map ()
 
Iterator begin ()
 
ConstIterator begin () const
 
ConstIterator cbegin () const
 
Iterator end ()
 
ConstIterator end () const
 
ConstIterator cend () const
 
Map< Key, T > & insert (const Key &key, const T &value)
 
Map< Key, T > & clear ()
 
unsigned int size () const
 
bool isEmpty () const
 
Iterator find (const Key &key)
 
ConstIterator find (const Key &key) const
 
bool contains (const Key &key) const
 
Map< Key, T > & erase (Iterator it)
 
Map< Key, T > & erase (const Key &key)
 
value (const Key &key, const T &defaultValue=T()) const
 
const T & operator[] (const Key &key) const
 
T & operator[] (const Key &key)
 
Map< Key, T > & operator= (const Map< Key, T > &m)
 
Map< Key, T > & operator= (std::initializer_list< std::pair< const Key, T > > init)
 
void swap (Map< Key, T > &m) noexcept
 
bool operator== (const Map< Key, T > &m) const
 
bool operator!= (const Map< Key, T > &m) const
 

Protected Member Functions

void detach ()
 

Detailed Description

template<class Key, class T>
class TagLib::Map< Key, T >

A generic, implicitly shared map.

This implements a standard map container that associates a key with a value and has fast key-based lookups. This map is also implicitly shared making it suitable for pass-by-value usage.

Constructor & Destructor Documentation

◆ Map() [1/3]

template<class Key , class T >
TagLib::Map< Key, T >::Map ( )

Constructs an empty Map.

◆ Map() [2/3]

template<class Key , class T >
TagLib::Map< Key, T >::Map ( const Map< Key, T > &  m)

Make a shallow, implicitly shared, copy of m. Because this is implicitly shared, this method is lightweight and suitable for pass-by-value usage.

◆ Map() [3/3]

template<class Key , class T >
TagLib::Map< Key, T >::Map ( std::initializer_list< std::pair< const Key, T > >  init)

Constructs a Map with the contents of the braced initializer list.

◆ ~Map()

template<class Key , class T >
TagLib::Map< Key, T >::~Map ( )

Destroys this instance of the Map.

Member Function Documentation

◆ begin() [1/2]

template<class Key , class T >
Iterator TagLib::Map< Key, T >::begin ( )

Returns an STL style iterator to the beginning of the map. See std::map::iterator for the semantics.

◆ begin() [2/2]

template<class Key , class T >
ConstIterator TagLib::Map< Key, T >::begin ( ) const

Returns an STL style iterator to the beginning of the map. See std::map::const_iterator for the semantics.

◆ cbegin()

template<class Key , class T >
ConstIterator TagLib::Map< Key, T >::cbegin ( ) const

Returns an STL style iterator to the beginning of the map. See std::map::const_iterator for the semantics.

◆ cend()

template<class Key , class T >
ConstIterator TagLib::Map< Key, T >::cend ( ) const

Returns an STL style iterator to the end of the map. See std::map::const_iterator for the semantics.

◆ clear()

template<class Key , class T >
Map< Key, T > & TagLib::Map< Key, T >::clear ( )

Removes all of the elements from the map. This however will not delete pointers if the mapped type is a pointer type.

◆ contains()

template<class Key , class T >
bool TagLib::Map< Key, T >::contains ( const Key &  key) const

Returns true if the map contains an item for key.

◆ detach()

template<class Key , class T >
void TagLib::Map< Key, T >::detach ( )
protected

If this Map is being shared via implicit sharing, do a deep copy of the data and separate from the shared members. This should be called by all non-const subclass members without Iterator parameters.

◆ end() [1/2]

template<class Key , class T >
Iterator TagLib::Map< Key, T >::end ( )

Returns an STL style iterator to the end of the map. See std::map::iterator for the semantics.

◆ end() [2/2]

template<class Key , class T >
ConstIterator TagLib::Map< Key, T >::end ( ) const

Returns an STL style iterator to the end of the map. See std::map::const_iterator for the semantics.

◆ erase() [1/2]

template<class Key , class T >
Map< Key, T > & TagLib::Map< Key, T >::erase ( const Key &  key)

Erase the item with key from the map.

◆ erase() [2/2]

template<class Key , class T >
Map< Key, T > & TagLib::Map< Key, T >::erase ( Iterator  it)

Erase the item at it from the map.

Note
This method cannot detach because it is tied to the internal map. Do not make an implicitly shared copy of this map between getting the iterator and calling this method!

◆ find() [1/2]

template<class Key , class T >
Iterator TagLib::Map< Key, T >::find ( const Key &  key)

Find the first occurrence of key.

◆ find() [2/2]

template<class Key , class T >
ConstIterator TagLib::Map< Key, T >::find ( const Key &  key) const

Find the first occurrence of key.

◆ insert()

template<class Key , class T >
Map< Key, T > & TagLib::Map< Key, T >::insert ( const Key &  key,
const T &  value 
)

Inserts value under key in the map. If a value for key already exists it will be overwritten.

◆ isEmpty()

template<class Key , class T >
bool TagLib::Map< Key, T >::isEmpty ( ) const

Returns true if the map is empty.

See also
size()

◆ operator!=()

template<class Key , class T >
bool TagLib::Map< Key, T >::operator!= ( const Map< Key, T > &  m) const

Compares this map with m and returns true if the maps differ.

◆ operator=() [1/2]

template<class Key , class T >
Map< Key, T > & TagLib::Map< Key, T >::operator= ( const Map< Key, T > &  m)

Make a shallow, implicitly shared, copy of m. Because this is implicitly shared, this method is lightweight and suitable for pass-by-value usage.

◆ operator=() [2/2]

template<class Key , class T >
Map< Key, T > & TagLib::Map< Key, T >::operator= ( std::initializer_list< std::pair< const Key, T > >  init)

Replace the contents of the map with those of the braced initializer list

◆ operator==()

template<class Key , class T >
bool TagLib::Map< Key, T >::operator== ( const Map< Key, T > &  m) const

Compares this map with m and returns true if all of the elements are the same.

◆ operator[]() [1/2]

template<class Key , class T >
T & TagLib::Map< Key, T >::operator[] ( const Key &  key)

Returns a reference to the value associated with key.

Note
This has undefined behavior if the key is not present in the map.

◆ operator[]() [2/2]

template<class Key , class T >
const T & TagLib::Map< Key, T >::operator[] ( const Key &  key) const

Returns a reference to the value associated with key.

Note
This has undefined behavior if the key is not present in the map.

◆ size()

template<class Key , class T >
unsigned int TagLib::Map< Key, T >::size ( ) const

The number of elements in the map.

See also
isEmpty()

◆ swap()

template<class Key , class T >
void TagLib::Map< Key, T >::swap ( Map< Key, T > &  m)
noexcept

Exchanges the content of this map with the content of m.

◆ value()

template<class Key , class T >
T TagLib::Map< Key, T >::value ( const Key &  key,
const T &  defaultValue = T() 
) const

Returns the value associated with key.

If the map does not contain key, it returns defaultValue. If no defaultValue is specified, it returns a default-constructed value.


The documentation for this class was generated from the following file: