link result view and source view
This commit is contained in:
22
linetolinemap.py
Normal file
22
linetolinemap.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import os
|
||||
import tempfile
|
||||
from typing import Optional
|
||||
|
||||
from int2intmap import Int2IntMap
|
||||
|
||||
|
||||
class LineToLineMap:
|
||||
def __init__(self):
|
||||
(handle, self.tmpfilename) = tempfile.mkstemp()
|
||||
os.close(handle)
|
||||
self._int2intmap = Int2IntMap(self.tmpfilename)
|
||||
|
||||
def close(self):
|
||||
self._int2intmap.close()
|
||||
os.remove(self.tmpfilename)
|
||||
|
||||
def add_line(self, key_byte_start: int, value_byte_start):
|
||||
self._int2intmap.add(key_byte_start, value_byte_start)
|
||||
|
||||
def get_line(self, key_byte_start: int) -> Optional[int]:
|
||||
return self._int2intmap.find(key_byte_start)
|
||||
Reference in New Issue
Block a user