Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/iron_hammer/utils/windows.rb,
lib/iron_hammer/utils/topological_sort.rb

Instance Method Summary collapse

Instance Method Details

#patheticalizeObject



13
14
15
# File 'lib/iron_hammer/utils/windows.rb', line 13

def patheticalize
  IronHammer::Utils::Windows::patheticalize *self
end

#topological_sortObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/iron_hammer/utils/topological_sort.rb', line 3

def topological_sort
  graph = {}
  refs = {}
  set = []
  list = []
  self.each {|e| set << e.name if e.project_references.empty?}
  self.each {|e| graph[e.name] = []; refs[e.name] = []}
  self.each do |e|
    e.project_references.each do |r|
      graph[r] << e.name if graph[r]
      refs[e.name] << r if refs[e.name]
    end
  end

  until set.empty?
    n = set.pop
    list << n
    until graph[n].empty?
      m = graph[n].pop
      refs[m].delete n
      set << m if refs[m].empty? && !set.include?(m)
    end
  end

  list.map {|e| self.find {|p| p.name == e}}
end