class Array

Public Instance Methods

dups() click to toggle source
# File lib/origen/core_ext/array.rb, line 10
def dups
  (select { |e| rindex(e) != index(e) }).uniq
end
dups?() click to toggle source
# File lib/origen/core_ext/array.rb, line 6
def dups?
  find { |e| rindex(e) != index(e) } ? true : false
end
dups_with_index() click to toggle source
# File lib/origen/core_ext/array.rb, line 14
def dups_with_index
  return {} unless dups?

  hash = Hash.new { |h, k| h[k] = [] }
  each_with_index do |val, idx|
    hash[val] << idx
  end
  hash.delete_if { |_k, v| v.size == 1 }
  hash
end
ids() click to toggle source
# File lib/origen/core_ext/array.rb, line 2
def ids
  map(&:id)
end
include_hash?() click to toggle source
# File lib/origen/core_ext/array.rb, line 25
def include_hash?
  each { |e| return true if e.is_a? Hash }
  false
end
include_hash_with_key?(key) click to toggle source
# File lib/origen/core_ext/array.rb, line 30
def include_hash_with_key?(key)
  each do |e|
    if e.is_a? Hash
      return e if e.key?(key)
    end
  end
  nil
end