Skip to content

Commit

Permalink
minor: removedead code
Browse files Browse the repository at this point in the history
  • Loading branch information
dmishin committed Dec 6, 2014
1 parent 0fcc211 commit 316b801
Showing 1 changed file with 5 additions and 67 deletions.
72 changes: 5 additions & 67 deletions scripts-src/rle.coffee
Original file line number Diff line number Diff line change
@@ -1,71 +1,9 @@
###
Library for RLE ensocing and decoding, used by Life programs
###
# Requires: nothing.
###
Encoder, creating RLE string from cell data
###
class RLEEncoder
constructor: ->
@stack = []
@cur_item = null
#
# Library for RLE ensocing and decoding, used by Life programs
#
# Parse Life RLE string, producing 2 arrays: Xs and Ys.
#

get_cur_char: ->
ci = @cur_item
unless ci?
null
else
ci[0]

put_cell: (value) -> @put (if value then "o" else "b")

newline: -> @put "$"

put: (c) ->
throw "Character " + c + " is wrong" unless c in ["b", "o", "$"]
cur_char = @get_cur_char()
if c is cur_char
@cur_item[1] += 1
else
if c is "$" and cur_char is "b"
@pop()
@put c
else
@cur_item = [c, 1]
@stack.push @cur_item

pop: ->
stk = @stack
stk.pop()
if stk.length is 0
@cur_item = null
else
@cur_item = stk[stk.length - 1]

trim_zeros: ->
stk = @stack
loop
len = stk.length
if len > 0
c = stk[len - 1][0]
if c is "$" or c is "b"
stk.pop()
continue
break

get_rle: ->
@trim_zeros()
output = ""
for [c, cnt] in @stack
if cnt > 1
output += cnt
output += c
output


###
Parse Life RLE string, producing 2 arrays: Xs and Ys.
###
exports.parse_rle = (rle_string, put_cell) ->
x = 0
y = 0
Expand Down

0 comments on commit 316b801

Please sign in to comment.