Lines Matching refs:self

186     def __init__(self):
188 self.entry_set = set()
189 self.widths = []
191 def append(self, codepoint: Codepoint, width: EffectiveWidth):
193 self.entry_set.add((codepoint, width))
194 self.widths.append(width)
196 def try_extend(self, attempt: "Bucket") -> bool:
197 """If either `self` or `attempt`'s width list starts with the other bucket's width list,
198 set `self`'s width list to the longer of the two, add all of `attempt`'s codepoints
199 into `self`, and return `True`. Otherwise, return `False`."""
200 (less, more) = (self.widths, attempt.widths)
201 if len(self.widths) > len(attempt.widths):
202 (less, more) = (attempt.widths, self.widths)
205 self.entry_set |= attempt.entry_set
206 self.widths = more
209 def entries(self) -> "list[tuple[Codepoint, EffectiveWidth]]":
211 result = list(self.entry_set)
215 def width(self) -> "EffectiveWidth":
218 if len(self.widths) == 0:
220 potential_width = self.widths[0]
221 for width in self.widths[1:]:
255 self, entry_groups, low_bit: BitPos, cap_bit: BitPos, offset_type: OffsetType
261 self.low_bit = low_bit
262 self.cap_bit = cap_bit
263 self.offset_type = offset_type
264 self.entries = []
265 self.indexed = []
269 buckets.extend(make_buckets(entries, self.low_bit, self.cap_bit))
272 for (i, existing) in enumerate(self.indexed):
274 self.entries.append(i)
277 self.entries.append(len(self.indexed))
278 self.indexed.append(bucket)
281 for index in self.entries:
282 assert index < (1 << int(self.offset_type))
284 def indices_to_widths(self):
287 self.entries = list(map(lambda i: int(self.indexed[i].width()), self.entries))
288 del self.indexed
290 def buckets(self):
292 return self.indexed
294 def to_bytes(self) -> "list[int]":
299 entries_per_byte = 8 // int(self.offset_type)
301 for i in range(0, len(self.entries), entries_per_byte):
304 byte |= self.entries[i + j] << (j * int(self.offset_type))
358 use core::option::Option::{self, None, Some};