Go to the documentation of this file.00001 #ifndef __TemBigrams_H_
00002 #define __TemBigrams_H_
00003
00004 struct CTempBigram
00005 {
00006 DWORD m_RightTokenId;
00007 DWORD m_LeftTokenId;
00008 DWORD m_RightTokenCorpusAddress;
00009 char m_Distance;
00010 bool LessWithoutAddress (const CTempBigram& X) const
00011 {
00012 if (m_RightTokenId != X.m_RightTokenId)
00013 return m_RightTokenId < X.m_RightTokenId;
00014
00015 if (m_LeftTokenId != X.m_LeftTokenId)
00016 return m_LeftTokenId < X.m_LeftTokenId;
00017
00018 return m_Distance < X.m_Distance;
00019 }
00020
00021 bool operator < (const CTempBigram& X) const
00022 {
00023 if (m_RightTokenId != X.m_RightTokenId)
00024 return m_RightTokenId < X.m_RightTokenId;
00025
00026 if (m_LeftTokenId != X.m_LeftTokenId)
00027 return m_LeftTokenId < X.m_LeftTokenId;
00028
00029 if (m_Distance != X.m_Distance)
00030 return m_Distance < X.m_Distance;
00031
00032 return m_RightTokenCorpusAddress < X.m_RightTokenCorpusAddress;
00033
00034 }
00035 void InitUnknown()
00036 {
00037 m_RightTokenId = UINT_MAX;
00038 m_LeftTokenId = UINT_MAX;
00039 m_Distance = CHAR_MAX;
00040 }
00041
00042 };
00043
00044 inline size_t get_size_in_bytes (const CTempBigram& t)
00045 {
00046 return sizeof (t.m_RightTokenId)
00047 + sizeof (t.m_LeftTokenId)
00048 + sizeof (t.m_RightTokenCorpusAddress)
00049 + sizeof (t.m_Distance)
00050 ;
00051 };
00052
00053 inline size_t save_to_bytes(const CTempBigram& i, BYTE* buf)
00054 {
00055 buf += save_to_bytes(i.m_RightTokenId, buf);
00056 buf += save_to_bytes(i.m_LeftTokenId, buf);
00057 buf += save_to_bytes(i.m_RightTokenCorpusAddress, buf);
00058 buf += save_to_bytes(i.m_Distance, buf);
00059 return get_size_in_bytes(i);
00060 }
00061
00062 inline size_t restore_from_bytes(CTempBigram& i, const BYTE* buf)
00063 {
00064 buf += restore_from_bytes(i.m_RightTokenId, buf);
00065 buf += restore_from_bytes(i.m_LeftTokenId, buf);
00066 buf += restore_from_bytes(i.m_RightTokenCorpusAddress, buf);
00067 buf += restore_from_bytes(i.m_Distance, buf);
00068
00069 return get_size_in_bytes(i);
00070 }
00071
00072
00073 #endif