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, replace_method, #reset_typespec, #tail

Class Method Details

.from_enumerable(type, arr) ⇒ Object



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

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

Instance Method Details

#prepend(data) ⇒ Object



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

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