Class: Contrek::Concurrent::Sequence

Inherits:
Object
  • Object
show all
Includes:
Queueable
Defined in:
lib/contrek/finder/concurrent/sequence.rb

Instance Attribute Summary collapse

Attributes included from Queueable

#head, #size, #tail

Instance Method Summary collapse

Methods included from Queueable

#add, #append, #each, #forward!, #iterator, #map, #move_from, #next_of!, #pop!, #rem, #remove_adjacent_pairs!, #replace!, #reset!, #reverse_each, #rewind!, #singleton!, #to_a

Constructor Details

#initializeSequence

Returns a new instance of Sequence.



7
8
9
# File 'lib/contrek/finder/concurrent/sequence.rb', line 7

def initialize
  @vertical_bounds = nil
end

Instance Attribute Details

#shapeObject

Returns the value of attribute shape.



4
5
6
# File 'lib/contrek/finder/concurrent/sequence.rb', line 4

def shape
  @shape
end

#vertical_boundsObject

Returns the value of attribute vertical_bounds.



4
5
6
# File 'lib/contrek/finder/concurrent/sequence.rb', line 4

def vertical_bounds
  @vertical_bounds
end

Instance Method Details

#compute_vertical_bounds!Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/contrek/finder/concurrent/sequence.rb', line 22

def compute_vertical_bounds!
  return if size == 0
  min_y = Float::INFINITY
  max_y = 0
  get_vector_cache.each do |pos|
    y = pos[:y]
    min_y = y if y < min_y
    max_y = y if y > max_y
  end
  @vertical_bounds = {min: min_y, max: max_y}
end

#get_vector_cacheObject



34
35
36
# File 'lib/contrek/finder/concurrent/sequence.rb', line 34

def get_vector_cache
  @vector_cache ||= to_a
end

#is_not_verticalObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/contrek/finder/concurrent/sequence.rb', line 11

def is_not_vertical
  return false if size < 2
  x0 = head.payload[:x]
  rewind!
  while (position = iterator)
    return true if position.payload[:x] != x0
    forward!
  end
  false
end