class XArray
need to figure out how left and right things work …
OK this is cool, things on the right if more than one go in one array ... or a non-array if just one item
Constants
- LAM_ISORT
- LAM_SSORT
Public Class Methods
new(obj=[])
click to toggle source
# File lib/primitive_wrapper.rb, line 1155 def initialize(obj=[]) obj = obj.prim_value ensure_valid(obj) @value = obj end
Public Instance Methods
[](*list)
click to toggle source
# File lib/primitive_wrapper.rb, line 1178 def [](*list) list = PrimitiveWrapper::get_list(list,size) if list.empty? return nil elsif list.count==1 if list.first == :all return @value elsif list.first.type_of? Range # get_list may pick this appart rtn = [] list.first.to_wrapper.re_range(size).each do |idx| rtn.push @value[idx] end return rtn else return @value[list.first] end end rtn = [] # for now keep this here until you can justify that it is not needed list.each do |ii| # I don't need to do this do I ??? get_list should untangle things if ii.type_of? Range ii.to_wrapper.re_range(size).each do |idx| rtn.push @value[idx] end elsif ii.type_of? Array ii.each do |idx| rtn.push @value[idx] end else rtn.push @value[ii] end end return rtn end
[]=(*list)
click to toggle source
# File lib/primitive_wrapper.rb, line 1212 def []=(*list) data = list.pop list = PrimitiveWrapper::get_list(list,size) return nil if list.empty? if list.count==1 if list.first.respond_to? :each list = list.first if list.type_of? Range list = list.to_xr.re_range(size) end end end if list.count==1 if list.first == :all PrimitiveWrapper.copy(@value, data, :all) end idxs = list.first if (idxs.respond_to? :each) if idxs.type_of? Range idxs = idxs.to_xr.re_range(size) end idxs.each do |idx| @value[idx] = data end else @value[idxs] = data end else if data.type_of? Array data = PrimitiveWrapper::get_list(data,size) end PrimitiveWrapper.copy(@value, data, list) end end
delete_at(*index_list)
click to toggle source
# File lib/primitive_wrapper.rb, line 1246 def delete_at(*index_list) return nil if index_list.empty? rtn = [] if (index_list.count==1) if index_list.first==:all rtn = @value.dup @value.empty! return rtn else ii = index_list.first rtn = self[ii] if ii.type_of? Range ii = ii.to_xr ii.re_range!(size) ii.reorder! ii.reverse_each do |idx| @value.delete_at(idx) end return rtn end end end rtn = self[*index_list] list = PrimitiveWrapper::get_list(index_list,size) list = list & list # remove duplicates list.sort.reverse.each do |idx| if idx.type_of? Range t_idx = idx.reorder else t_idx = idx end @value.delete_at(t_idx) end return rtn end
include?(*list)
click to toggle source
# File lib/primitive_wrapper.rb, line 1281 def include?(*list) # replace with list of stuff if list.count==1 if list.first.respond_to? :each list = list.first end end list.each do |item| return false unless @value.include? item end true end
include_any?(*list)
click to toggle source
# File lib/primitive_wrapper.rb, line 1292 def include_any?(*list) # replace with list of stuff if list.count==1 if list.first.respond_to? :each list = list.first end end list.each do |item| return true if @value.include? item end false end
isort()
click to toggle source
# File lib/primitive_wrapper.rb, line 1166 def isort @value.sort &LAM_ISORT end
isort!()
click to toggle source
# File lib/primitive_wrapper.rb, line 1169 def isort! @value.sort! &LAM_ISORT end
ssort()
click to toggle source
# File lib/primitive_wrapper.rb, line 1172 def ssort @value.sort &LAM_SSORT end
ssort!()
click to toggle source
# File lib/primitive_wrapper.rb, line 1175 def ssort! @value.sort! &LAM_SSORT end
valid_type(prm)
click to toggle source
# File lib/primitive_wrapper.rb, line 1161 def valid_type(prm) return true if prm.kind_of? Array return true if prm.kind_of? XArray false end