MCPcopy Create free account
hub / github.com/activeloopai/deeplake / random_string

Function random_string

cpp/base/random.hpp:178–191  ·  view source on GitHub ↗

* @brief Generates a random string of a given size from a given set of characters. * @param size Size of the string to generate. * @param chrs Set of characters to use for the string. * @return A random string of the given size. */

Source from the content-addressed store, hash-verified

176 * @return A random string of the given size.
177 */
178inline std::string random_string(int size,
179 const std::string_view chrs = "0123456789"
180 "abcdefghijklmnopqrstuvwxyz"
181 "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
182{
183 auto& rg = random_engine();
184 std::uniform_int_distribution<std::string::size_type> pick(0, chrs.size()-1);
185 std::string s;
186 s.reserve(size);
187 while(size--) {
188 s += chrs[pick(rg)];
189 }
190 return s;
191}
192
193/**
194 * @brief Uses the random_string function to generate a random uuid-formatted string. Not a true uuid, but random enough

Callers 1

random_uuidFunction · 0.70

Calls 2

sizeMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected