HArray is an implemenation of the Array class using only Hashes. Regular Arrays are never used except once to delegate the pack method, and for *args parameters (since there is no way around those is some cases). HArray is for all practical purposes 100% compatible with Array.
HArray is slower then the built in Array class, but not as slow as one might expect, since a Hash in general is faster than an Array. It might be interesting to see how this would perform if it were written in c. Not all that useful, but an interesting example.
AUTHOR(s)
- Thamas Sawyer
Methods
- &
- *
- +
- -
- <<
- <=>
- ===
- []
- []
- []=
- assoc
- at
- collect
- collect!
- compact
- compact!
- concat
- count
- delete
- delete_at
- delete_if
- each
- each_index
- eql?
- fill
- first
- flatten
- flatten!
- include?
- join
- last
- map!
- new
- new_h
- nitems
- pack
- pop
- push
- qsort
- rassoc
- reindex
- reindex!
- reject!
- reverse
- reverse!
- reverse_each
- rindex
- shift
- slice
- slice!
- sort
- sort!
- to_a
- to_ary
- to_h
- to_s
- uniq
- uniq!
- unshift
- values_at
- |
Public Class methods
[](*args)
[ source ]
new(i=0,e=nil)
[ source ]
new_h(hsh)
[ source ]
Public Instance methods
&(ha)
[ source ]
*(j)
[ source ]
+(ha)
[ source ]
-(ha)
[ source ]
<<(e)
[ source ]
<=>(ha)
[ source ]
===(ha)
[ source ]
[](i,l=nil)
[ source ]
[]=(i,b,c=nil)
[ source ]
assoc(k)
[ source ]
at(i)
[ source ]
collect() {|self.fetch(i)| ...}
[ source ]
clear okay
compact()
[ source ]
compact!()
[ source ]
concat(ha)
[ source ]
count(e=nil) {|self.fetch(i)| ...}
[ source ]
delete(e) {|if block_given?| ...}
[ source ]
delete_at(i)
[ source ]
delete_if() {|v| ...}
[ source ]
each() {|self.fetch(i)| ...}
[ source ]
each_index() {|i| ...}
[ source ]
eql?(ha)
[ source ]
empty? okay as is
fill(f,s=nil,l=nil)
[ source ]
first()
[ source ]
flatten()
[ source ]
flatten!()
[ source ]
include?(v)
[ source ]
join(sep='')
[ source ]
index okay
last()
[ source ]
Alias for collect!
nitems()
[ source ]
pack(*args)
[ source ]
pop()
[ source ]
push(*e)
[ source ]
qsort(ha, l, r)
[ source ]
rassoc(k)
[ source ]
reindex()
[ source ]
reindex!()
[ source ]
reject!() {|v| ...}
[ source ]
reverse()
[ source ]
def replace(ha)
if ha.length < self.length
(ha.length..self.length-1).each { |i| self.delete(i) }
(0..ha.length-1).each { |i| self.set(i,ha[i]) }
end
end
reverse!()
[ source ]
reverse_each() {|self.fetch(i)| ...}
[ source ]
rindex(e)
[ source ]
shift()
[ source ]
slice(*args)
[ source ]
size okay
slice!(*args)
[ source ]
sort()
[ source ]
sort!()
[ source ]
to_a()
[ source ]
to_ary()
[ source ]
to_h()
[ source ]
to_s()
[ source ]
uniq()
[ source ]
uniq!()
[ source ]
unshift(e)
[ source ]
values_at(*ix)
[ source ]
|(ha)
[ source ]