Skip to content
This repository has been archived by the owner on Oct 21, 2021. It is now read-only.

Commit

Permalink
sizehint -> sizehint!
Browse files Browse the repository at this point in the history
  • Loading branch information
mlubin committed Jan 24, 2015
1 parent d018f24 commit 4c28698
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
julia 0.3
DataStructures 0.2.9-
Compat
1 change: 1 addition & 0 deletions src/Graphs.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Graphs
using DataStructures
using Compat

import Base: start, done, next, show, ==
import Base: length, isempty, size, getindex, isless
Expand Down
4 changes: 2 additions & 2 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function collect_edges{V,E}(graph::AbstractGraph{V,E})

elseif implements_vertex_list(graph) && implements_incidence_list(graph)
edge_list = Array(E, 0)
sizehint(edge_list, num_edges(graph))
sizehint!(edge_list, num_edges(graph))

for v in vertices(graph)
for e in out_edges(v, graph)
Expand All @@ -229,7 +229,7 @@ function collect_weighted_edges{V,E,W}(graph::AbstractGraph{V,E}, weights::Abstr
edge_property_requirement(weights, graph)

wedges = Array(WeightedEdge{E,W}, 0)
sizehint(wedges, num_edges(graph))
sizehint!(wedges, num_edges(graph))

if implements_edge_list(graph)
for e in edges(graph)
Expand Down
2 changes: 1 addition & 1 deletion src/depth_first_visit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ type TopologicalSortVisitor{V} <: AbstractGraphVisitor

function TopologicalSortVisitor(n::Int)
vs = Array(Int, 0)
sizehint(vs, n)
sizehint!(vs, n)
new(vs)
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/gmatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ function sparse2adjacencylist{Tv,Ti<:Integer}(A::SparseMatrixCSC{Tv,Ti})
s = 0
for j in 1:n
adjj = Ti[]
sizehint(adjj, colptr[j+1] - colptr[j] - 1)
sizehint!(adjj, colptr[j+1] - colptr[j] - 1)
for k in colptr[j]:(colptr[j+1] - 1)
rvk = A.rowval[k]
if rvk != j push!(adjj, rvk) end
Expand Down
2 changes: 1 addition & 1 deletion src/graph_visit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type VertexListVisitor{V} <: AbstractGraphVisitor

function VertexListVisitor(n::Integer=0)
vs = Array(V, 0)
sizehint(vs, n)
sizehint!(vs, n)
new(vs)
end
end
Expand Down
6 changes: 3 additions & 3 deletions src/kruskal_mst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function kruskal_select{V,E,W}(

if n > 1
dsets = IntDisjointSets(n)
sizehint(re, n-1)
sizehint(rw, n-1)
sizehint!(re, n-1)
sizehint!(rw, n-1)

ui::Int = 0
vi::Int = 0
Expand Down Expand Up @@ -56,4 +56,4 @@ end
function kruskal_minimum_spantree(graph::AbstractGraph, eweights::AbstractVector; K::Integer=1)
visitor::AbstractEdgePropertyInspector = VectorEdgePropertyInspector(eweights)
kruskal_minimum_spantree(graph, visitor, K=K)
end
end
4 changes: 2 additions & 2 deletions src/prim_mst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ function default_prim_visitor{V,E,W}(g::AbstractGraph{V,E}, ::Type{W})
weights = Array(W, 0)
n = num_vertices(g)
if n > 1
sizehint(edges, n-1)
sizehint(weights, n-1)
sizehint!(edges, n-1)
sizehint!(weights, n-1)
end
PrimVisitor{E,W}(edges, weights)
end
Expand Down

0 comments on commit 4c28698

Please sign in to comment.