mirror of
https://github.com/izzy2lost/Torch.git
synced 2026-07-06 00:18:35 -07:00
Fixed AIFC Extraction
This commit is contained in:
@@ -132,10 +132,11 @@ void LUS::BinaryWriter::Write(double value) {
|
||||
mStream->Write((char*)&value, sizeof(double));
|
||||
}
|
||||
|
||||
void LUS::BinaryWriter::Write(const std::string& str) {
|
||||
int strLen = str.size();
|
||||
Write(strLen);
|
||||
|
||||
void LUS::BinaryWriter::Write(const std::string& str, bool writeLength) {
|
||||
if(writeLength){
|
||||
int strLen = str.size();
|
||||
Write(strLen);
|
||||
}
|
||||
for (char c : str) {
|
||||
mStream->WriteByte(c);
|
||||
}
|
||||
@@ -145,6 +146,10 @@ void LUS::BinaryWriter::Write(char* srcBuffer, size_t length) {
|
||||
mStream->Write(srcBuffer, length);
|
||||
}
|
||||
|
||||
void LUS::BinaryWriter::WriteByte(char value) {
|
||||
mStream->WriteByte(value);
|
||||
}
|
||||
|
||||
std::vector<char> LUS::BinaryWriter::ToVector() {
|
||||
return mStream->ToVector();
|
||||
}
|
||||
|
||||
@@ -33,8 +33,9 @@ class BinaryWriter {
|
||||
void Write(uint64_t value);
|
||||
void Write(float value);
|
||||
void Write(double value);
|
||||
void Write(const std::string& str);
|
||||
void Write(const std::string& str, bool writeLength = true);
|
||||
void Write(char* srcBuffer, size_t length);
|
||||
void WriteByte(char value);
|
||||
|
||||
std::vector<char> ToVector();
|
||||
|
||||
|
||||
+38
-4
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace PyUtils {
|
||||
template<typename T>
|
||||
@@ -12,12 +13,45 @@ std::vector<T> slice(std::vector<T> const &v, uint32_t m, uint32_t n = -1) {
|
||||
return vec;
|
||||
}
|
||||
|
||||
std::vector<uint32_t> range(uint32_t start, uint32_t end) {
|
||||
std::vector<uint32_t> result;
|
||||
for (uint32_t i = start; i < end; ++i) {
|
||||
result.push_back(i);
|
||||
std::vector<uint32_t> range(uint32_t start, uint32_t end);
|
||||
|
||||
template<typename T>
|
||||
T max(std::vector<T> const &v) {
|
||||
T max = v[0];
|
||||
for (auto const &value: v) {
|
||||
if (value > max) {
|
||||
max = value;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
template<typename T>
|
||||
T min(std::vector<T> const &v) {
|
||||
T min = v[0];
|
||||
for (auto const &value: v) {
|
||||
if (value < min) {
|
||||
min = value;
|
||||
}
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
template<typename T, typename X>
|
||||
std::vector<T> keys(std::unordered_map<T, X> const &map) {
|
||||
std::vector<T> result;
|
||||
for (auto const &pair: map) {
|
||||
result.push_back(pair.first);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> operator+(std::vector<T> const &x, std::vector<T> const &y)
|
||||
{
|
||||
std::vector<T> vec;
|
||||
vec.reserve(x.size() + y.size());
|
||||
vec.insert(vec.end(), x.begin(), x.end());
|
||||
vec.insert(vec.end(), y.begin(), y.end());
|
||||
return vec;
|
||||
}
|
||||
Reference in New Issue
Block a user