Sha256: 595d378c0b931e8dc200a5cbbd6245832620735c0d5bc1f99bfc2ac99420db58

Contents?: true

Size: 471 Bytes

Versions: 4

Compression:

Stored size: 471 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

4 entries across 4 versions & 1 rubygems

Version Path
gir_ffi-0.15.3 lib/ffi-glib/s_list.rb
gir_ffi-0.15.2 lib/ffi-glib/s_list.rb
gir_ffi-0.15.1 lib/ffi-glib/s_list.rb
gir_ffi-0.15.0 lib/ffi-glib/s_list.rb