diff --git a/std/n8std/Array.cc b/std/n8std/Array.cc index cccdda9..281ea2f 100644 --- a/std/n8std/Array.cc +++ b/std/n8std/Array.cc @@ -28,7 +28,7 @@ N8_FUNC(array_create) { for(size_t i = 0; i < args.size(); i++) { DynamicObject item = args.at(i); - values.emplace_back(item); + values.push_back(item); } return DynamicObject( @@ -146,7 +146,7 @@ N8_FUNC(array_last) { } N8_FUNC(array_add) { - if(args.size() > 1) + if(args.size() <= 1) throw TerminativeThrowSignal( std::move(address), "Expecting greater than 1 argument, got " + @@ -164,7 +164,7 @@ N8_FUNC(array_add) { auto array = value.getArray(); for(size_t i = 1; i < args.size(); i++) { DynamicObject item = args.at(i); - array->emplace_back(item); + array->push_back(item); } return DynamicObject(array); diff --git a/std/n8std/IO.cc b/std/n8std/IO.cc index 6287d51..6ad1463 100644 --- a/std/n8std/IO.cc +++ b/std/n8std/IO.cc @@ -97,8 +97,8 @@ N8_FUNC(io_fileRead) { std::vector returnValues; if(!file) { - returnValues.emplace_back(DynamicObject()); - returnValues.emplace_back( + returnValues.push_back(DynamicObject()); + returnValues.push_back( DynamicObject("Error: Could not open the file " + fileName.toString()) ); @@ -106,8 +106,8 @@ N8_FUNC(io_fileRead) { } std::string content((std::istreambuf_iterator(file)), std::istreambuf_iterator()); - returnValues.emplace_back(content); - returnValues.emplace_back(DynamicObject()); + returnValues.push_back(content); + returnValues.push_back(DynamicObject()); return DynamicObject(std::make_shared>(returnValues)); } @@ -144,16 +144,16 @@ N8_FUNC(io_fileSize) { std::vector returnValues; if(!file) { - returnValues.emplace_back(DynamicObject(0.0)); - returnValues.emplace_back(DynamicObject(false)); + returnValues.push_back(DynamicObject(0.0)); + returnValues.push_back(DynamicObject(false)); return DynamicObject(std::make_shared>(returnValues)); } - returnValues.emplace_back(DynamicObject( + returnValues.push_back(DynamicObject( static_cast(file.tellg()) )); - returnValues.emplace_back(DynamicObject(true)); + returnValues.push_back(DynamicObject(true)); return DynamicObject(std::make_shared>(returnValues)); } @@ -172,8 +172,8 @@ N8_FUNC(io_filePerms) { DWORD attributes = GetFileAttributes(fileName.toString().c_str()); if(attributes == INVALID_FILE_ATTRIBUTES) { - returnValues.emplace_back(DynamicObject(0.0)); - returnValues.emplace_back(DynamicObject("Could not get file attributes")); + returnValues.push_back(DynamicObject(0.0)); + returnValues.push_back(DynamicObject("Could not get file attributes")); return DynamicObject(std::make_shared>(returnValues)); } @@ -187,8 +187,8 @@ N8_FUNC(io_filePerms) { struct stat fileStat; if(stat(fileName.toString().c_str(), &fileStat) != 0) { - returnValues.emplace_back(DynamicObject(0.0)); - returnValues.emplace_back(DynamicObject("Could not get file status")); + returnValues.push_back(DynamicObject(0.0)); + returnValues.push_back(DynamicObject("Could not get file status")); return DynamicObject(std::make_shared>(returnValues)); } @@ -206,8 +206,8 @@ N8_FUNC(io_filePerms) { #endif - returnValues.emplace_back(DynamicObject(static_cast(permissions))); - returnValues.emplace_back(DynamicObject()); + returnValues.push_back(DynamicObject(static_cast(permissions))); + returnValues.push_back(DynamicObject()); return DynamicObject(std::make_shared>(returnValues)); } @@ -225,8 +225,8 @@ N8_FUNC(io_fileCreationDate) { std::filesystem::path filePath(fileName.toString().c_str()); if(!std::filesystem::exists(filePath)) { - returnValues.emplace_back(DynamicObject(0.0)); - returnValues.emplace_back(DynamicObject("File does not exist")); + returnValues.push_back(DynamicObject(0.0)); + returnValues.push_back(DynamicObject("File does not exist")); } else { auto creationTime = std::filesystem::last_write_time(filePath); @@ -236,8 +236,8 @@ N8_FUNC(io_fileCreationDate) { ); auto ctime = std::chrono::system_clock::to_time_t(sctp); - returnValues.emplace_back(DynamicObject(0.0)); - returnValues.emplace_back(DynamicObject( + returnValues.push_back(DynamicObject(0.0)); + returnValues.push_back(DynamicObject( static_cast(ctime) )); } @@ -261,12 +261,12 @@ N8_FUNC(io_fileDelete) { #ifdef _WIN32 if(DeleteFile(fileName.toString().c_str())) { - returnValues.emplace_back(DynamicObject(true)); - returnValues.emplace_back(DynamicObject()); + returnValues.push_back(DynamicObject(true)); + returnValues.push_back(DynamicObject()); } else { - returnValues.emplace_back(DynamicObject(false)); - returnValues.emplace_back(DynamicObject("Could not delete file")); + returnValues.push_back(DynamicObject(false)); + returnValues.push_back(DynamicObject("Could not delete file")); } #else @@ -274,17 +274,17 @@ N8_FUNC(io_fileDelete) { struct stat buffer; if(stat(fileName.toString().c_str(), &buffer) == 0) { if(remove(fileName.toString().c_str()) == 0) { - returnValues.emplace_back(DynamicObject(true)); - returnValues.emplace_back(DynamicObject()); + returnValues.push_back(DynamicObject(true)); + returnValues.push_back(DynamicObject()); } else { - returnValues.emplace_back(DynamicObject(false)); - returnValues.emplace_back(DynamicObject("Could not delete file")); + returnValues.push_back(DynamicObject(false)); + returnValues.push_back(DynamicObject("Could not delete file")); } } else { - returnValues.emplace_back(DynamicObject(false)); - returnValues.emplace_back(DynamicObject("File does not exist")); + returnValues.push_back(DynamicObject(false)); + returnValues.push_back(DynamicObject("File does not exist")); } #endif @@ -305,21 +305,21 @@ N8_FUNC(io_folderCreate) { std::filesystem::path folderPath(folderName.toString().c_str()); if(std::filesystem::exists(folderPath)) { - returnValues.emplace_back(DynamicObject(false)); - returnValues.emplace_back(DynamicObject("Folder already exists")); + returnValues.push_back(DynamicObject(false)); + returnValues.push_back(DynamicObject("Folder already exists")); return DynamicObject(std::make_shared>(returnValues)); } if(std::filesystem::create_directory(folderPath)) { - returnValues.emplace_back(DynamicObject(true)); - returnValues.emplace_back(DynamicObject()); + returnValues.push_back(DynamicObject(true)); + returnValues.push_back(DynamicObject()); return DynamicObject(std::make_shared>(returnValues)); } - returnValues.emplace_back(DynamicObject(false)); - returnValues.emplace_back(DynamicObject("Could not create folder")); + returnValues.push_back(DynamicObject(false)); + returnValues.push_back(DynamicObject("Could not create folder")); return DynamicObject(std::make_shared>(returnValues)); } @@ -338,8 +338,8 @@ N8_FUNC(io_folderSize) { unsigned long long totalSize = 0; if(!std::filesystem::exists(path) || !std::filesystem::is_directory(path)) { - returnValues.emplace_back(DynamicObject(0.0)); - returnValues.emplace_back(DynamicObject( + returnValues.push_back(DynamicObject(0.0)); + returnValues.push_back(DynamicObject( "Provided path is not a directory or does not exist" )); @@ -351,8 +351,8 @@ N8_FUNC(io_folderSize) { if(std::filesystem::is_regular_file(entry)) totalSize += std::filesystem::file_size(entry); - returnValues.emplace_back(DynamicObject(static_cast(totalSize))); - returnValues.emplace_back(DynamicObject()); + returnValues.push_back(DynamicObject(static_cast(totalSize))); + returnValues.push_back(DynamicObject()); return DynamicObject(std::make_shared>(returnValues)); } @@ -370,8 +370,8 @@ N8_FUNC(io_folderCreationDate) { std::filesystem::path filePath(folderName.toString().c_str()); if(!std::filesystem::exists(filePath)) { - returnValues.emplace_back(DynamicObject(0.0)); - returnValues.emplace_back(DynamicObject("File does not exist")); + returnValues.push_back(DynamicObject(0.0)); + returnValues.push_back(DynamicObject("File does not exist")); } else { auto creationTime = std::filesystem::last_write_time(filePath); @@ -381,8 +381,8 @@ N8_FUNC(io_folderCreationDate) { ); auto ctime = std::chrono::system_clock::to_time_t(sctp); - returnValues.emplace_back(DynamicObject(0.0)); - returnValues.emplace_back(DynamicObject( + returnValues.push_back(DynamicObject(0.0)); + returnValues.push_back(DynamicObject( static_cast(ctime) )); } @@ -469,7 +469,7 @@ N8_FUNC(io_listAllFiles) { #pragma omp parallel for for(const auto& entry : std::filesystem::directory_iterator(dirPath)) - returnValues.emplace_back(DynamicObject( + returnValues.push_back(DynamicObject( entry.path().filename().string() )); diff --git a/std/n8std/ML.cc b/std/n8std/ML.cc index 17b8b76..29dc2a1 100644 --- a/std/n8std/ML.cc +++ b/std/n8std/ML.cc @@ -105,8 +105,8 @@ N8_FUNC(ml_trendline_calculate) { double slope = numerator / denominator; std::vector returnValues; - returnValues.emplace_back(DynamicObject(slope)); - returnValues.emplace_back(DynamicObject(y - slope * x)); + returnValues.push_back(DynamicObject(slope)); + returnValues.push_back(DynamicObject(y - slope * x)); return DynamicObject(std::make_shared>( returnValues @@ -153,14 +153,14 @@ N8_FUNC(ml_trendline_calculateRmse) { #pragma omp parallel for for(size_t i = 0; i < paramSize; i++) { std::vector model; - model.emplace_back(regModel.at(0)); - model.emplace_back(regModel.at(1)); + model.push_back(regModel.at(0)); + model.push_back(regModel.at(1)); std::vector params; - params.emplace_back(DynamicObject( + params.push_back(DynamicObject( std::make_shared>(model) )); - params.emplace_back(xObjArray[i]); + params.push_back(xObjArray[i]); double yPred = ml_trendline_predict( std::move(address), diff --git a/std/n8std/Math.cc b/std/n8std/Math.cc index 823781b..535082f 100644 --- a/std/n8std/Math.cc +++ b/std/n8std/Math.cc @@ -431,8 +431,8 @@ N8_FUNC(math_splitExponent) { result = frexp(param, &n); std::vector returnValues; - returnValues.emplace_back(DynamicObject(result)); - returnValues.emplace_back(DynamicObject(static_cast(n))); + returnValues.push_back(DynamicObject(result)); + returnValues.push_back(DynamicObject(static_cast(n))); return DynamicObject(std::make_shared>( returnValues @@ -791,8 +791,8 @@ N8_FUNC(math_remQuotient) { result = remquo(xn, yn, &n); std::vector returnValues; - returnValues.emplace_back(DynamicObject(result)); - returnValues.emplace_back(DynamicObject(static_cast(n))); + returnValues.push_back(DynamicObject(result)); + returnValues.push_back(DynamicObject(static_cast(n))); return DynamicObject(std::make_shared>( returnValues @@ -1016,13 +1016,13 @@ N8_FUNC(math_softmax) { for(size_t i = 0; i < len; i++) { double temp = exp(values.at(i).getNumber() - max); - probabilities.emplace_back(temp); + probabilities.push_back(temp); sum += temp; } std::vector results; for(size_t i = 0; i < len; i++) - results.emplace_back(DynamicObject(probabilities[i] / sum)); + results.push_back(DynamicObject(probabilities[i] / sum)); return DynamicObject(std::make_shared>( results