Class: GLib::SList

Inherits:
Object
  • Object
show all
Includes:
ListMethods
Defined in:
lib/ffi-glib/s_list.rb

Overview

Overrides for GSList, GLib’s singly-linked list implementation.

Instance Attribute Summary

Attributes included from ListMethods

#element_type

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ListMethods

#==, #each, #head, included, #initialize, replace_method, #reset_typespec, #tail

Class Method Details

.from_enumerable(type, arr) ⇒ Object



12
13
14
# File 'lib/ffi-glib/s_list.rb', line 12

def self.from_enumerable(type, arr)
  arr.reverse.reduce(new(type)) { |lst, val| lst.prepend val }
end

Instance Method Details

#prepend(data) ⇒ Object



16
17
18
19
# File 'lib/ffi-glib/s_list.rb', line 16

def prepend(data)
  self.class.wrap(element_type,
                  Lib.g_slist_prepend(self, element_ptr_for(data)))
end