Apollo 11.0
自动驾驶开放平台
apollo::planning::IndexedList< I, T > 模板类 参考

#include <indexed_list.h>

类 apollo::planning::IndexedList< I, T > 继承关系图:
apollo::planning::IndexedList< I, T > 的协作图:

Public 成员函数

T * Add (const I id, const T &object)
 copy object into the container.
 
T * Find (const I id)
 Find object by id in the container
 
const T * Find (const I id) const
 Find object by id in the container
 
const std::vector< const T * > & Items () const
 List all the items in the container.
 
const std::unordered_map< I, T > & Dict () const
 List all the items in the container.
 
IndexedListoperator= (const IndexedList &other)
 Copy the container with objects.
 

详细描述

template<typename I, typename T>
class apollo::planning::IndexedList< I, T >

在文件 indexed_list.h35 行定义.

成员函数说明

◆ Add()

template<typename I , typename T >
T * apollo::planning::IndexedList< I, T >::Add ( const I  id,
const T &  object 
)
inline

copy object into the container.

If the id is already exist, overwrite the object in the container.

参数
idthe id of the object
objectthe const reference of the objected to be copied to the container.
返回
The pointer to the object in the container.

在文件 indexed_list.h45 行定义.

45 {
46 auto obs = Find(id);
47 if (obs) {
48 AWARN << "object " << id << " is already in container";
49 *obs = object;
50 return obs;
51 } else {
52 object_dict_.insert({id, object});
53 auto* ptr = &object_dict_.at(id);
54 object_list_.push_back(ptr);
55 return ptr;
56 }
57 }
T * Find(const I id)
Find object by id in the container
#define AWARN
Definition log.h:43

◆ Dict()

template<typename I , typename T >
const std::unordered_map< I, T > & apollo::planning::IndexedList< I, T >::Dict ( ) const
inline

List all the items in the container.

返回
the unordered_map of ids and objects in the container.

在文件 indexed_list.h89 行定义.

89{ return object_dict_; }

◆ Find() [1/2]

template<typename I , typename T >
T * apollo::planning::IndexedList< I, T >::Find ( const I  id)
inline

Find object by id in the container

参数
idthe id of the object
返回
the raw pointer to the object if found.
nullptr if the object is not found.

在文件 indexed_list.h65 行定义.

65 {
66 return apollo::common::util::FindOrNull(object_dict_, id);
67 }

◆ Find() [2/2]

template<typename I , typename T >
const T * apollo::planning::IndexedList< I, T >::Find ( const I  id) const
inline

Find object by id in the container

参数
idthe id of the object
返回
the raw pointer to the object if found.
nullptr if the object is not found.

在文件 indexed_list.h75 行定义.

75 {
76 return apollo::common::util::FindOrNull(object_dict_, id);
77 }

◆ Items()

template<typename I , typename T >
const std::vector< const T * > & apollo::planning::IndexedList< I, T >::Items ( ) const
inline

List all the items in the container.

返回
the list of const raw pointers of the objects in the container.

在文件 indexed_list.h83 行定义.

83{ return object_list_; }

◆ operator=()

template<typename I , typename T >
IndexedList & apollo::planning::IndexedList< I, T >::operator= ( const IndexedList< I, T > &  other)
inline

Copy the container with objects.

在文件 indexed_list.h94 行定义.

94 {
95 this->object_list_.clear();
96 this->object_dict_.clear();
97 for (const auto& item : other.Dict()) {
98 Add(item.first, item.second);
99 }
100 return *this;
101 }
const std::unordered_map< I, T > & Dict() const
List all the items in the container.
T * Add(const I id, const T &object)
copy object into the container.

该类的文档由以下文件生成: