예제 #1
0
 /// <summary>
 /// Replaces entry IDs with file positions in list. Called when finalizing index.
 /// </summary>
 private static void replaceIdsWithPositions(List <IdeoEntryPtr> list, Dictionary <int, int> idToPos)
 {
     for (int i = 0; i != list.Count; ++i)
     {
         int  id  = list[i].EntryIdx;
         byte cnt = list[i].HwCharCount;
         int  pos = idToPos[id];
         list[i] = new IdeoEntryPtr {
             EntryIdx = pos, HwCharCount = cnt
         };
     }
 }
예제 #2
0
        /// <summary>
        /// Serializes object into a binary stream.
        /// </summary>
        public void Serialize(BinWriter bw)
        {
            int cntSimp = EntriesHeadwordSimp.Count;

            bw.WriteInt(cntSimp);
            for (int i = 0; i != cntSimp; ++i)
            {
                IdeoEntryPtr iep = EntriesHeadwordSimp[i];
                bw.WriteInt(iep.EntryIdx);
                bw.WriteByte(iep.HwCharCount);
            }
            int cntTrad = EntriesHeadwordTrad.Count;

            bw.WriteInt(cntTrad);
            for (int i = 0; i != cntTrad; ++i)
            {
                IdeoEntryPtr iep = EntriesHeadwordTrad[i];
                bw.WriteInt(iep.EntryIdx);
                bw.WriteByte(iep.HwCharCount);
            }
            bw.WriteArray(EntriesSense, (i, bwr) => bwr.WriteInt(i));
        }
예제 #3
0
        /// <summary>
        /// Ctor: deserializes data from binary stream.
        /// </summary>
        public IdeoIndexItem(BinReader br)
        {
            int cntSimp = br.ReadInt();

            EntriesHeadwordSimp = new List <IdeoEntryPtr>(cntSimp);
            for (int i = 0; i != cntSimp; ++i)
            {
                IdeoEntryPtr iep = new IdeoEntryPtr {
                    EntryIdx = br.ReadInt(), HwCharCount = br.ReadByte()
                };
                EntriesHeadwordSimp.Add(iep);
            }
            int cntTrad = br.ReadInt();

            EntriesHeadwordTrad = new List <IdeoEntryPtr>(cntTrad);
            for (int i = 0; i != cntTrad; ++i)
            {
                IdeoEntryPtr iep = new IdeoEntryPtr {
                    EntryIdx = br.ReadInt(), HwCharCount = br.ReadByte()
                };
                EntriesHeadwordTrad.Add(iep);
            }
            EntriesSense = new List <int>(br.ReadArray(brr => brr.ReadInt()));
        }