Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change struct to serializable-struct. #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions graph/graph-unweighted.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(require "gen-graph.rkt"
"adjlist-utils.rkt")

(require racket/sequence racket/set racket/unsafe/ops)
(require racket/sequence racket/set racket/unsafe/ops racket/serialize)

; unweighted, adjacency-list graph

Expand All @@ -15,7 +15,7 @@
(define-syntax-rule (get-adjlist g) (unsafe-struct*-ref g 0))

;; A Graph is a (graph AdjacencyList)
(struct unweighted-graph (adjlist)
(serializable-struct unweighted-graph (adjlist)
#:methods gen:equal+hash
[(define (equal-proc g1 g2 equal?-recur)
(equal?-recur (get-adjlist g1) (get-adjlist g2)))
Expand Down
4 changes: 2 additions & 2 deletions graph/graph-weighted.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(require "adjlist-utils.rkt")
(require "graph-unweighted.rkt")

(require racket/sequence racket/set racket/unsafe/ops)
(require racket/sequence racket/set racket/unsafe/ops racket/serialize)

; weighted, adjacency-list graph

Expand All @@ -17,7 +17,7 @@
(define-syntax-rule (get-weights g) (unsafe-struct*-ref g 1))

;; A WeightedGraph is a (weighted-graph AdjacencyList Weights)
(struct weighted-graph (adjlist weights)
(serializable-struct weighted-graph (adjlist weights)
#:methods gen:equal+hash
[(define (equal-proc g1 g2 equal?-recur)
(and (equal?-recur (get-adjlist g1) (get-adjlist g2))
Expand Down
4 changes: 2 additions & 2 deletions queue/fifo.rkt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#lang racket/base
(require "gen-queue.rkt")
(require (prefix-in r: data/queue))
(require (prefix-in r: data/queue) racket/serialize)
(provide (all-defined-out))

(struct fifo (elements)
(serializable-struct fifo (elements)
#:methods gen:queue
[(define (enqueue! ff x) (r:enqueue! (fifo-elements ff) x))
(define (peek ff)
Expand Down
4 changes: 2 additions & 2 deletions queue/priority.rkt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#lang racket/base
(require "gen-queue.rkt")
(require (prefix-in r: data/heap))
(require (prefix-in r: data/heap) racket/serialize)
(provide (all-defined-out))

;; priority queue such that on dequeue of element x,
;; pop all copies of x from the queue

(struct priority (elements)
(serializable-struct priority (elements)
#:methods gen:queue
[(define (enqueue! pq x) (r:heap-add! (priority-elements pq) x))
(define (peek pq) (r:heap-min (priority-elements pq)))
Expand Down