Returns a random element of the Vector. */
| 258 | |
| 259 | /** Returns a random element of the Vector. */ |
| 260 | T getRandomObject() const |
| 261 | { |
| 262 | if (!_data.empty()) |
| 263 | { |
| 264 | ssize_t randIdx = RandomHelper::random_int<int>(0, static_cast<int>(_data.size()) - 1); |
| 265 | return *(_data.begin() + randIdx); |
| 266 | } |
| 267 | return nullptr; |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * Checks whether an object is in the container. |