add next_value for dictionary

also next for list
and add types attributes to space
This commit is contained in:
Torsten Ruger
2018-05-13 13:03:04 +03:00
parent 2d901bf7b6
commit 7ad36380c2
6 changed files with 53 additions and 2 deletions

View File

@ -30,6 +30,10 @@ module Parfait
return @keys.get_length()
end
def next_value(val)
return @values.next_value(val)
end
# get a value fot the given key
# key identity is checked with == not === (ie equals not identity)
# return nil if no such key

View File

@ -78,7 +78,7 @@ module Parfait
end
# include? means non nil index
def include? item
def include?( item )
return index_of(item) != nil
end
@ -97,6 +97,14 @@ module Parfait
return nil
end
# return the next of given. Nil if item not in list or there is not next
def next_value(val)
index = index_of(val)
return nil unless index
return nil if index == get_length
return get(index + 1)
end
# push means add to the end
# this automatically grows the List
def push( value )

View File

@ -50,7 +50,7 @@ module Parfait
@nil_object = Parfait::NilClass.new
end
attr_reader :classes , :first_message , :next_integer
attr_reader :classes , :types , :first_message , :next_integer
attr_reader :true_object , :false_object , :nil_object
def each_type