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

Update ordered_containers.md #870

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 14 additions & 2 deletions docs/src/ordered_containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ for c in 'a':'e'
end
collect(d) # => [('a',1),('b',2),('c',3),('d',4),('e',5)]

s = OrderedSet(π,e,γ,catalan,φ)
s = OrderedSet([π,e,γ,catalan,φ])
collect(s) # => [π = 3.1415926535897...,
# e = 2.7182818284590...,
# γ = 0.5772156649015...,
Expand All @@ -21,7 +21,18 @@ collect(s) # => [π = 3.1415926535897...,
```

All standard `Dict` functions are available for `OrderedDicts`, and
all `Set` operations are available for `OrderedSets`.
all `Set` operations are available for `OrderedSets`. A point to be careful about is that equality does not respect order. That is,
```julia
A1 = OrderedSet(["a", "b"])
A2 = OrderedSet(["b", "a"])
A1 == A2 # true
collect(A1) == collect(A2) # false

B1 = OrderedDict("a" => 1, "b" => 2)
B2 = OrderedDict("b" => 2, "a" => 1)
B1 == B2 # true
collect(B1) == collect(B2) # false
```

Note that to create an `OrderedSet` of a particular type, you must specify
the type in curly-braces:
Expand All @@ -30,3 +41,4 @@ the type in curly-braces:
# create an OrderedSet of Strings
strs = OrderedSet{AbstractString}()
```

Loading