public const_iterator(FileMappedVector fileMappedVector, ulong index) { this.m_fileMappedVector = new FileMappedVector(fileMappedVector); //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: this.m_index = index; this.m_index.CopyFrom(index); }
public void swap(FileMappedVector other) { m_path.swap(other.m_path); m_file.swap(other.m_file); std::swap(m_prefixSize, other.m_prefixSize); std::swap(m_suffixSize, other.m_suffixSize); }
//C++ TO C# CONVERTER TODO TASK: The original C++ template specifier was replaced with a C# generic specifier, which may not produce the same behavior: //ORIGINAL LINE: template<class F> //C++ TO C# CONVERTER TODO TASK: 'rvalue references' have no equivalent in C#: private void atomicUpdate0 <F>(ulong newCapacity, ulong newPrefixSize, ulong newSuffixSize, F&& func) { if (m_file.path() != m_path) { throw new System.Exception("Vector is mapped to a .bak file due to earlier errors"); } boost::filesystem.path bakPath = m_path + ".bak"; boost::filesystem.path tmpPath = boost::filesystem.unique_path(m_path + ".tmp.%%%%-%%%%"); if (boost::filesystem.exists(bakPath)) { boost::filesystem.remove(bakPath); } Tools.ScopeExit tmpFileDeleter(() => { boost::system.error_code ignore = new boost::system.error_code(); boost::filesystem.remove(tmpPath, ignore); }); // Copy file. It is slow but atomic operation FileMappedVector <T> tmpVector = new FileMappedVector <T>(); tmpVector.create(tmpPath.string(), new ulong(newCapacity), new ulong(newPrefixSize), new ulong(newSuffixSize)); func(tmpVector); tmpVector.flush(); // Swap files std::error_code ec = new std::error_code(); std::error_code ignore = new std::error_code(); m_file.rename(bakPath.string()); tmpVector.rename(m_path, ec); if (ec != null) { // Try to restore and ignore errors m_file.rename(m_path, ignore); throw std::system_error(ec, "Failed to swap temporary and vector files"); } m_path = bakPath.string(); swap(tmpVector); tmpFileDeleter.cancel(); // Remove .bak file and ignore errors tmpVector.close(ignore); boost::system.error_code boostError = new boost::system.error_code(); boost::filesystem.remove(bakPath, boostError); }
public iterator(FileMappedVector fileMappedVector, ulong index) : base(fileMappedVector, new ulong(index)) { }