aboutsummaryrefslogtreecommitdiff
path: root/src/lzss/lzsschain.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/lzss/lzsschain.nim')
-rw-r--r--src/lzss/lzsschain.nim17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/lzss/lzsschain.nim b/src/lzss/lzsschain.nim
index 8ebcb1a..ab03655 100644
--- a/src/lzss/lzsschain.nim
+++ b/src/lzss/lzsschain.nim
@@ -14,26 +14,23 @@
14# You should have received a copy of the GNU Affero General Public License 14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <https://www.gnu.org/licenses/>. 15# along with this program. If not, see <https://www.gnu.org/licenses/>.
16 16
17import lists, tables, sugar 17import tables, sugar
18import ../bitio/integers 18import ../bitio/integers
19import listpolyfill, lzssnode 19import lzssnode
20 20
21const maxChainByteLength = 32_000 * wordBitLength 21const maxChainByteLength = 32_000
22 22
23type LzssChain* = 23type LzssChain* = seq[LzssNode]
24 SinglyLinkedList[LzssNode]
25 24
26proc lzssChain*(): LzssChain = 25proc lzssChain*(): LzssChain =
27 initSinglyLinkedList[LzssNode]() 26 newSeq[LzssNode]()
28 27
29proc lzssChain*(chainArray: openArray[LzssNode]): LzssChain = 28proc lzssChain*(chainArray: openArray[LzssNode]): LzssChain =
30 var chain = lzssChain() 29 @chainArray
31 for node in chainArray: chain.append(node)
32 chain
33 30
34proc decode*(lzssChain: LzssChain): seq[uint8] = 31proc decode*(lzssChain: LzssChain): seq[uint8] =
35 result = newSeqOfCap[uint8](maxChainByteLength) 32 result = newSeqOfCap[uint8](maxChainByteLength)
36 for node in lzssChain.items: 33 for node in lzssChain:
37 case node.kind: 34 case node.kind:
38 of character: 35 of character:
39 result.add(node.character) 36 result.add(node.character)