Sha256: 38bcc76c32e3b238521fc778e4d4d7b8f410a2d690cad0a22677a4dc237deb06

Contents?: true

Size: 439 Bytes

Versions: 8

Compression:

Stored size: 439 Bytes

Contents

require 'ffi-glib/list_methods'

GLib.load_class :SList

module GLib
  # Overrides for GSList, GLib's singly-linked list implementation.
  class SList
    include ListMethods

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

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gir_ffi-0.9.0 lib/ffi-glib/s_list.rb
gir_ffi-0.8.6 lib/ffi-glib/s_list.rb
gir_ffi-0.8.5 lib/ffi-glib/s_list.rb
gir_ffi-0.8.4 lib/ffi-glib/s_list.rb
gir_ffi-0.8.3 lib/ffi-glib/s_list.rb
gir_ffi-0.8.2 lib/ffi-glib/s_list.rb
gir_ffi-0.8.1 lib/ffi-glib/s_list.rb
gir_ffi-0.8.0 lib/ffi-glib/s_list.rb