problemscpp
A collection of my answers to algorithm problems in c++.
|
#include <leetcode.h>
Public 成员函数 | |
RandomizedSet () | |
Initializes the RandomizedSet object. 更多... | |
int | getRandom () |
Returns a random element from the current set of elements (it's guaranteed that at least one element exists when this method is called). Each element must have the same probability of being returned. 更多... | |
bool | insert (int val) |
Inserts an item val into the set if not present. 更多... | |
bool | remove (int val) |
Removes an item val from the set if present. 更多... | |
Private 属性 | |
uniform_int_distribution< int > | distribution |
default_random_engine | generator |
unordered_map< int, int > | map |
vector< int > | nums |
在文件 leetcode.h 第 2217 行定义.
leetcode::insert_delete_getrandom_o1::RandomizedSet::RandomizedSet | ( | ) |
Initializes the RandomizedSet object.
在文件 leetcode.cpp 第 5959 行定义.
引用了 distribution , 以及 generator.
int leetcode::insert_delete_getrandom_o1::RandomizedSet::getRandom | ( | ) |
Returns a random element from the current set of elements (it's guaranteed that at least one element exists when this method is called). Each element must have the same probability of being returned.
在文件 leetcode.cpp 第 5986 行定义.
引用了 distribution, generator , 以及 nums.
bool leetcode::insert_delete_getrandom_o1::RandomizedSet::insert | ( | int | val | ) |
Inserts an item val into the set if not present.
在文件 leetcode.cpp 第 5964 行定义.
bool leetcode::insert_delete_getrandom_o1::RandomizedSet::remove | ( | int | val | ) |
Removes an item val from the set if present.
在文件 leetcode.cpp 第 5973 行定义.
|
private |
在文件 leetcode.h 第 2221 行定义.
被这些函数引用 RandomizedSet() , 以及 getRandom().
|
private |
在文件 leetcode.h 第 2220 行定义.
被这些函数引用 RandomizedSet() , 以及 getRandom().
|
private |
在文件 leetcode.h 第 2218 行定义.
|
private |
在文件 leetcode.h 第 2219 行定义.
被这些函数引用 getRandom(), insert() , 以及 remove().