Generic doubly linked list. #361

Merged
merged 5 commits into from May 3, 2017

Conversation

Projects
None yet
3 participants
@AndreaOrru
Member

AndreaOrru commented May 3, 2017

This implements a generic doubly linked list in the standard library.

std/linked_list.zig
+ const List = this;
+
+ /// Node inside the linked list wrapping the actual data.
+ const Node = struct {

This comment has been minimized.

@thejoshwolfe

thejoshwolfe May 3, 2017

Member

shouldn't this be pub?

@thejoshwolfe

thejoshwolfe May 3, 2017

Member

shouldn't this be pub?

This comment has been minimized.

@AndreaOrru

AndreaOrru May 3, 2017

Member

Yeah, I don't see why not. Using the list requires knowledge of the internals of Node (the data field). Also the developer may want to allocate some Nodes independently (perhaps statically).

@AndreaOrru

AndreaOrru May 3, 2017

Member

Yeah, I don't see why not. Using the list requires knowledge of the internals of Node (the data field). Also the developer may want to allocate some Nodes independently (perhaps statically).

This comment has been minimized.

@thejoshwolfe

thejoshwolfe May 3, 2017

Member

I'm surprised this isn't a compile error.

@thejoshwolfe

thejoshwolfe May 3, 2017

Member

I'm surprised this isn't a compile error.

This comment has been minimized.

@AndreaOrru

AndreaOrru May 3, 2017

Member

@andrewrk you think this should be a compile error?

@AndreaOrru

AndreaOrru May 3, 2017

Member

@andrewrk you think this should be a compile error?

This comment has been minimized.

@andrewrk

andrewrk May 3, 2017

Member

Where would the compile error be?

here?

    var one   = %%list.createNode(1);

error: one has type Node which is private
note: declared here

@andrewrk

andrewrk May 3, 2017

Member

Where would the compile error be?

here?

    var one   = %%list.createNode(1);

error: one has type Node which is private
note: declared here

This comment has been minimized.

@thejoshwolfe

thejoshwolfe May 3, 2017

Member

the error should be on line 181

@thejoshwolfe

thejoshwolfe May 3, 2017

Member

the error should be on line 181

This comment has been minimized.

@andrewrk

andrewrk May 3, 2017

Member

ok, I made #362 for this, I think we're still good to merge the PR

@andrewrk

andrewrk May 3, 2017

Member

ok, I made #362 for this, I think we're still good to merge the PR

+ ///
+ /// Returns:
+ /// A pointer to the new node.
+ pub fn createNode(list: &List, data: &const T) -> %&Node {

This comment has been minimized.

@thejoshwolfe

thejoshwolfe May 3, 2017

Member

error: cannot expose non-pub type Node in pub method signature.

@thejoshwolfe

thejoshwolfe May 3, 2017

Member

error: cannot expose non-pub type Node in pub method signature.

@andrewrk andrewrk merged commit 6f66691 into ziglang:master May 3, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment