Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
|
|
@ -1,6 +1,9 @@
|
|||
Base.start(ll::LinkedList) = ll.head
|
||||
Base.done(ll::LinkedList{T}, st::AbstractNode{T}) where T = st isa EmptyNode
|
||||
Base.next(ll::LinkedList{T}, st::AbstractNode{T}) where T = st.data, st.next
|
||||
Base.iterate(ll::LinkedList) = iterate(ll, ll.head)
|
||||
Base.iterate(::LinkedList, st::Node) = st.data, st.next
|
||||
Base.iterate(::LinkedList, ::EmptyNode) = nothing
|
||||
Base.length(ll::LinkedList) = 1 + length(ll.next)
|
||||
Base.length(ll::EmptyNode) = 0
|
||||
Base.eltype(::LinkedList{T}) where {T} = T
|
||||
|
||||
lst = LinkedList{Int}()
|
||||
push!(lst, 1)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
require "list"
|
||||
local fmt = require "fmt"
|
||||
|
||||
-- Create a singly-linked list containing the first 50 positive integers.
|
||||
local s = slist.of(range(1, 50):unpack())
|
||||
|
||||
-- Now traverse and print them in tabular form.
|
||||
local node = s:node(1)
|
||||
local count = 0
|
||||
while node do
|
||||
fmt.write("%4d ", node.value)
|
||||
node = node.next
|
||||
if ++count % 10 == 0 then print() end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue