本文整理汇总了C++中std::array::fill方法的典型用法代码示例。如果您正苦于以下问题:C++ array::fill方法的具体用法?C++ array::fill怎么用?C++ array::fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::array
的用法示例。
在下文中一共展示了array::fill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eval
void eval(MonteCarloNode& n) {
auto& b = n.board;
auto sym = n.orientation;
feats.fill(Features());
oriented.fill(Features());
extractFeatures(b,feats);
dihedralTranspose(feats,oriented,sym);
inVec.clear();
convertToTCNNInput(oriented,inVec);
result = &nn.fprop(inVec);
std::vector<size_t> inds;
inds.assign(n.moves.size(),0);
double total = 0;
for(size_t i = 0; i < n.moves.size(); ++i) {
inds[i] = /*IX(n.moves[i]);*/IX(dihedral(n.moves[i],sym));
total += (*result)[inds[i]];
}
for(size_t i = 0; i < n.moves.size(); ++i) {
n.probabilities[i].store((*result)[inds[i]]/total);
}
}
示例2: update_ctrlkeys
void update_ctrlkeys()
{
SDL_PumpEvents();
ctrlkeys.fill(0);
auto r = SDL_GetModState();
if (r & KMOD_RSHIFT)
ctrlkeys[0] |= 1;
if (r & KMOD_LSHIFT)
ctrlkeys[0] |= 2;
//if (r & KMOD_SCROLL)
// ctrlkeys[0] |= 16;
if (r & KMOD_LALT)
ctrlkeys[0] |= 16;
// relocating this to right alt instead of left alt
if (r & KMOD_RALT)
ctrlkeys[0] |= 32;
if (r & KMOD_CAPS)
ctrlkeys[0] |= 64;
}
示例3: isDisplayable
bool Validator::isDisplayable(const Action::Type type)
{
if (type == Action::Type::anyItem)
return true;
const auto displayedType = [this](Action::Type t) -> bool & {
return displayedType_[static_cast<std::size_t>(t)];
};
if (! checkedType_) {
displayedType_.fill(true);
for (const QString & name : itemNames_) {
if (QFileInfo(commonItemPrefix_ + name).isDir()) {
displayedType(Action::Type::file) = false;
if (! displayedType(Action::Type::directory))
break; // both file and dir were found.
}
else {
displayedType(Action::Type::directory) = false;
if (! displayedType(Action::Type::file))
break; // both file and dir were found.
}
}
checkedType_ = true;
}
return displayedType(type);
}
示例4: RegisterKernelFunction
void
Module::registerMembaseFunctions()
{
sMemArenas.fill(nullptr);
RegisterKernelFunction(MEMGetBaseHeapHandle);
RegisterKernelFunction(MEMSetBaseHeapHandle);
RegisterKernelFunction(MEMGetArena);
RegisterKernelFunction(MEMiInitHeapHead);
RegisterKernelFunction(MEMiFinaliseHeap);
RegisterKernelFunction(MEMFindContainHeap);
RegisterKernelFunction(MEMDumpHeap);
RegisterKernelDataName("MEMAllocFromDefaultHeap", pMEMAllocFromDefaultHeap);
RegisterKernelDataName("MEMAllocFromDefaultHeapEx", pMEMAllocFromDefaultHeapEx);
RegisterKernelDataName("MEMFreeToDefaultHeap", pMEMFreeToDefaultHeap);
RegisterInternalFunction(internal::defaultAllocFromDefaultHeap, sDefaultMEMAllocFromDefaultHeap);
RegisterInternalFunction(internal::defaultAllocFromDefaultHeapEx, sDefaultMEMAllocFromDefaultHeapEx);
RegisterInternalFunction(internal::defaultFreeToDefaultHeap, sDefaultMEMFreeToDefaultHeap);
RegisterInternalData(sForegroundMemlist);
RegisterInternalData(sMEM1Memlist);
RegisterInternalData(sMEM2Memlist);
}
示例5: clear
void clear() {
csi = false;
state = State::Ground;
postfix = '\0';
parms.fill(0);
inside.clear();
parm_count = 0;
}
示例6: InverseAlphabet
explicit
InverseAlphabet(std::string const& digits)
{
map_.fill(-1);
int i = 0;
for(auto const c : digits)
map_[static_cast<
unsigned char>(c)] = i++;
}
示例7: hist
bool hist(cv::Mat img, std::array<unsigned int, 256>& bins) {
assert(img.type() == CV_8UC1);
bins.fill(0);
for(int row = 0; row < img.rows; ++row) {
uchar* p = img.ptr(row);
for(int col = 0; col < img.cols; ++col) {
++bins[*p++]; //points to each pixel value in turn assuming a CV_8UC1 greyscale image
}
}
return true;
}
示例8: SaveConfig
void ConfigCache::SaveConfig(const SConfig& config)
{
valid = true;
bCPUThread = config.bCPUThread;
bJITFollowBranch = config.bJITFollowBranch;
bEnableCheats = config.bEnableCheats;
bSyncGPUOnSkipIdleHack = config.bSyncGPUOnSkipIdleHack;
bFPRF = config.bFPRF;
bAccurateNaNs = config.bAccurateNaNs;
bMMU = config.bMMU;
m_EnableJIT = config.m_DSPEnableJIT;
bSyncGPU = config.bSyncGPU;
iSyncGpuMaxDistance = config.iSyncGpuMaxDistance;
iSyncGpuMinDistance = config.iSyncGpuMinDistance;
fSyncGpuOverclock = config.fSyncGpuOverclock;
bFastDiscSpeed = config.bFastDiscSpeed;
bDSPHLE = config.bDSPHLE;
bHLE_BS2 = config.bHLE_BS2;
iSelectedLanguage = config.SelectedLanguage;
cpu_core = config.cpu_core;
Volume = config.m_Volume;
m_EmulationSpeed = config.m_EmulationSpeed;
strBackend = config.m_strVideoBackend;
sBackend = config.sBackend;
m_strGPUDeterminismMode = config.m_strGPUDeterminismMode;
m_OCFactor = config.m_OCFactor;
m_OCEnable = config.m_OCEnable;
std::copy(std::begin(g_wiimote_sources), std::end(g_wiimote_sources), std::begin(iWiimoteSource));
std::copy(std::begin(config.m_SIDevice), std::end(config.m_SIDevice), std::begin(Pads));
std::copy(std::begin(config.m_EXIDevice), std::end(config.m_EXIDevice), std::begin(m_EXIDevice));
bSetEmulationSpeed = false;
bSetVolume = false;
bSetWiimoteSource.fill(false);
bSetPads.fill(false);
bSetEXIDevice.fill(false);
}
示例9: MEMInitList
void
Module::initialiseMembase()
{
sMemArenas.fill(nullptr);
MEMInitList(sForegroundMemlist, offsetof(CommonHeap, link));
MEMInitList(sMEM1Memlist, offsetof(CommonHeap, link));
MEMInitList(sMEM2Memlist, offsetof(CommonHeap, link));
CoreInitDefaultHeap();
// TODO: getAddress should not be neccessary here...
*pMEMAllocFromDefaultHeap = sDefaultMEMAllocFromDefaultHeap.getAddress();
*pMEMAllocFromDefaultHeapEx = sDefaultMEMAllocFromDefaultHeapEx.getAddress();
*pMEMFreeToDefaultHeap = sDefaultMEMFreeToDefaultHeap.getAddress();
}
示例10: main
int main( void ) {
dm.fill(0);
uint16_t max = 0;
uint32_t num = 0;
for (uint32_t i = 1; i < 1000000; ++i ){
uint16_t v = collatz(i);
dm.at(i-1) = v;
if (v > max) {
max = v;
num = i;
}
}
std::cout << num << std::endl;
return 0;
};
示例11: FormatConfig
ResultCode FormatConfig() {
ResultCode res = DeleteConfigNANDSaveFile();
if (!res.IsSuccess())
return res;
// Delete the old data
cfg_config_file_buffer.fill(0);
// Create the header
SaveFileConfig* config = reinterpret_cast<SaveFileConfig*>(cfg_config_file_buffer.data());
// This value is hardcoded, taken from 3dbrew, verified by hardware, it's always the same value
config->data_entries_offset = 0x455C;
// Insert the default blocks
res = CreateConfigInfoBlk(0x00050005, sizeof(STEREO_CAMERA_SETTINGS), 0xE,
reinterpret_cast<const u8*>(STEREO_CAMERA_SETTINGS.data()));
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(0x00090001, sizeof(CONSOLE_UNIQUE_ID), 0xE,
reinterpret_cast<const u8*>(&CONSOLE_UNIQUE_ID));
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(0x000F0004, sizeof(CONSOLE_MODEL), 0x8,
reinterpret_cast<const u8*>(&CONSOLE_MODEL));
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(0x000A0002, sizeof(CONSOLE_LANGUAGE), 0xA, &CONSOLE_LANGUAGE);
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(0x00070001, sizeof(SOUND_OUTPUT_MODE), 0xE, &SOUND_OUTPUT_MODE);
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(0x000B0000, sizeof(COUNTRY_INFO), 0xE,
reinterpret_cast<const u8*>(&COUNTRY_INFO));
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(0x000A0000, sizeof(CONSOLE_USERNAME_BLOCK), 0xE,
reinterpret_cast<const u8*>(&CONSOLE_USERNAME_BLOCK));
if (!res.IsSuccess())
return res;
// Save the buffer to the file
res = UpdateConfigNANDSavegame();
if (!res.IsSuccess())
return res;
return RESULT_SUCCESS;
}
示例12: onMessageReceived
void onMessageReceived(const error_code& ec, size_t nrBytes)
{
auto onMessageReceivedWrapper = [this](const error_code& ec,
size_t nrBytes)
{
this->onMessageReceived(ec, nrBytes);
};
cout << "Received " << data_.data() << "\n";
try
{
socket_.read_some(boost::asio::buffer(data_));
socket_.async_read_some(boost::asio::buffer(data_),
onMessageReceivedWrapper);
data_.fill(0);
}
catch(std::exception& e)
{
cout << e.what() << "\n";
}
}
示例13: MEMInitList
void
Module::initialiseMembase()
{
sSystemHeap = nullptr;
sMemArenas.fill(nullptr);
sForegroundMemlist = coreinit::internal::sysAlloc<MemoryList>();
MEMInitList(sForegroundMemlist, offsetof(CommonHeap, link));
sMEM1Memlist = coreinit::internal::sysAlloc<MemoryList>();
MEMInitList(sMEM1Memlist, offsetof(CommonHeap, link));
sMEM2Memlist = coreinit::internal::sysAlloc<MemoryList>();
MEMInitList(sMEM2Memlist, offsetof(CommonHeap, link));
CoreInitDefaultHeap();
*pMEMAllocFromDefaultHeap = findExportAddress("internal_defaultAlloc");
*pMEMAllocFromDefaultHeapEx = findExportAddress("internal_defaultAllocEx");
*pMEMFreeToDefaultHeap = findExportAddress("internal_defaultFree");
}
示例14: RegisterKernelFunction
void
Module::registerMembaseFunctions()
{
sMemArenas.fill(nullptr);
RegisterKernelFunction(MEMGetBaseHeapHandle);
RegisterKernelFunction(MEMSetBaseHeapHandle);
RegisterKernelFunction(MEMGetArena);
RegisterKernelDataName("MEMAllocFromDefaultHeap", pMEMAllocFromDefaultHeap);
RegisterKernelDataName("MEMAllocFromDefaultHeapEx", pMEMAllocFromDefaultHeapEx);
RegisterKernelDataName("MEMFreeToDefaultHeap", pMEMFreeToDefaultHeap);
RegisterKernelFunction(MEMiInitHeapHead);
RegisterKernelFunction(MEMiFinaliseHeap);
RegisterKernelFunction(MEMFindContainHeap);
RegisterKernelFunction(MEMDumpHeap);
// These are default implementations for function pointers, register as exports
// so we will have function thunks generated
RegisterKernelFunctionName("internal_defaultAlloc", coreinit::internal::defaultAllocFromDefaultHeap);
RegisterKernelFunctionName("internal_defaultAllocEx", coreinit::internal::defaultAllocFromDefaultHeapEx);
RegisterKernelFunctionName("internal_defaultFree", coreinit::internal::defaultFreeToDefaultHeap);
}
示例15:
void
Module::initialiseExceptions()
{
sExceptionCallbacks.fill(nullptr);
}