Class: Babeltrace::ListHead

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/babeltrace/list.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.del(p, n) ⇒ Object



28
29
30
31
# File 'lib/babeltrace/list.rb', line 28

def self.del(p, n)
  n[:prev] = p
  n[:next] = n
end

Instance Method Details

#add(head) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/babeltrace/list.rb', line 12

def add(head)
  head[:next][:prev] = self
  self[:next] = head[:next]
  self[:prev] = head
  head[:next] = self
  self
end

#add_tail(head) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/babeltrace/list.rb', line 20

def add_tail(head)
  head[:prev][:next] = self
  self[:next] = head
  self[:prev] = head[:prev]
  head[:prev] = self
  self
end

#delObject



33
34
35
36
# File 'lib/babeltrace/list.rb', line 33

def del
  ListHead.del(self[:prev], self[:next])
  self
end

#empty?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/babeltrace/list.rb', line 61

def empty?
  self.to_ptr == self[:next].to_ptr
end

#initObject



7
8
9
10
# File 'lib/babeltrace/list.rb', line 7

def init
  self[:next] = self[:prev] = self
  self
end

#move(list) ⇒ Object



38
39
40
41
42
# File 'lib/babeltrace/list.rb', line 38

def move(list)
  ListHead.del(self[:prev], self[:next])
  self.add(list)
  self
end

#replace(n) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/babeltrace/list.rb', line 44

def replace(n)
  n[:next] = self[:next]
  n[:prev] = self[:prev]
  n[:prev][:next] = n
  n[:next][:prev] = n
  self
end

#replace_init(n) ⇒ Object



65
66
67
68
69
70
# File 'lib/babeltrace/list.rb', line 65

def replace_init(n)
  head = self[:next]
  self.del
  n.add_tail(head)
  self.init
end

#splice(head) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/babeltrace/list.rb', line 52

def splice(head)
  if(!empty?)
    self[:next][:prev] = head
    self[:prev][:next] = head[:next]
    head[:next][:prev] = self[:prev]
    head[:next] = self[:next]
  end
end