2015-07-13 11:54:51 +00:00
|
|
|
from libcpp.vector cimport vector
|
|
|
|
from libc.stdint cimport uint32_t
|
|
|
|
from libc.stdint cimport int64_t
|
|
|
|
from libc.stdint cimport int32_t
|
|
|
|
from libc.stdint cimport uint64_t
|
|
|
|
|
2015-07-21 17:58:45 +00:00
|
|
|
from .bits cimport BitArray, Code
|
2015-07-16 17:55:47 +00:00
|
|
|
|
2015-07-13 11:54:51 +00:00
|
|
|
|
|
|
|
cdef struct Node:
|
|
|
|
int32_t left
|
|
|
|
int32_t right
|
|
|
|
|
|
|
|
|
|
|
|
cdef class HuffmanCodec:
|
|
|
|
cdef vector[Node] nodes
|
|
|
|
cdef vector[Code] codes
|
2015-07-19 15:58:44 +00:00
|
|
|
cdef Node root
|
|
|
|
|
|
|
|
cdef readonly list leaves
|
|
|
|
cdef readonly dict _map
|
2015-07-21 17:58:45 +00:00
|
|
|
|
|
|
|
cpdef int encode_int32(self, int32_t[:] msg, BitArray bits) except -1
|
|
|
|
cpdef int decode_int32(self, BitArray bits, int32_t[:] msg) except -1
|