I have two class StorageAddress and PersistentChunk. I define a map called SsdChunkMap.
typedef std::map<StorageAddress, PersistentChunk> SsdChunkMap;
SsdChunkMap* _SsdChunkMap;
I want to insert data to map.
StorageAddress _StorageAddress(victim._addr);
PersistentChunk _PersistentChunk(victim._hdr.pos.offs, victim._data,
victim._hdr.compressedSize);
_SsdChunkMap->insert(make_pair(_StorageAddress, _PersistentChunk));
And I overload the operator <
inline bool operator < (StorageAddress const& other) const
{
if(attId != other.attId)
{
return attId < other.attId;
}
if (coords.size() != other.coords.size())
{
return coords.size() < other.coords.size();
}
for (size_t i = 0, n = coords.size(); i < n; i++)
{
if (coords[i] != other.coords[i])
{
return coords[i] < other.coords[i];
}
}
if (arrId != other.arrId)
{
//note: reverse ordering to keep most-recent versions at the front of the map
return arrId > other.arrId;
}
return false;
}
_SsdChunkMap->insert(make_pair(_StorageAddress, _PersistentChunk));
So, this is right?