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



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

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

Instance Method Details

#prepend(data) ⇒ Object



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

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