Sha256: de76f78aef1afd07a730572942c448f576ae71bd9b5b79b7cf2ebfb4a441fa5d

Contents?: true

Size: 470 Bytes

Versions: 9

Compression:

Stored size: 470 Bytes

Contents

# frozen_string_literal: true
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

9 entries across 9 versions & 1 rubygems

Version Path
gir_ffi-0.11.1 lib/ffi-glib/s_list.rb
gir_ffi-0.11.0 lib/ffi-glib/s_list.rb
gir_ffi-0.10.2 lib/ffi-glib/s_list.rb
gir_ffi-0.10.1 lib/ffi-glib/s_list.rb
gir_ffi-0.10.0 lib/ffi-glib/s_list.rb
gir_ffi-0.10.0.pre1 lib/ffi-glib/s_list.rb
gir_ffi-0.9.5 lib/ffi-glib/s_list.rb
gir_ffi-0.9.4 lib/ffi-glib/s_list.rb
gir_ffi-0.9.3 lib/ffi-glib/s_list.rb