## vector-of-one-byte-unts.pkg
# Compiled by:
#
src/lib/std/src/standard-core.sublib### "Humor cannot do credit to itself without a
### good background of gravity & of earnestness.
###
### "Humor unsupported rather hurts its author
### in the estimation of the reader."
###
### -- Mark Twain,
### Letter to Michael Simons,
### January 1873
package vector_of_one_byte_unts: (weak) Typelocked_Vector { # Typelocked_Vector is from
src/lib/std/src/typelocked-vector.api #
package v = inline_t::vector_of_one_byte_unts; # inline_t is from
src/lib/core/init/built-in.pkg # Fast add/subtract avoiding
# the overflow test:
#
infix my --- +++;
#
fun x --- y = inline_t::tu::copyt_tagged_int (inline_t::tu::copyf_tagged_int x - inline_t::tu::copyf_tagged_int y);
fun x +++ y = inline_t::tu::copyt_tagged_int (inline_t::tu::copyf_tagged_int x + inline_t::tu::copyf_tagged_int y);
# Unchecked access operations:
#
unsafe_get = v::get;
unsafe_set = v::set;
Vector = v::Vector;
Element = one_byte_unt::Unt;
maximum_vector_length = core::maximum_vector_length;
length = v::length;
get = v::get_with_boundscheck;
(_[]) = get;
zero_length_vector = inline_t::cast "" : Vector;
create_vec = inline_t::cast runtime::asm::make_string : Int -> Vector;
from_list = inline_t::cast vector_of_chars::from_list : List(Element) -> Vector;
from_fn = inline_t::cast vector_of_chars::from_fn : (Int, (Int -> Element)) -> Vector;
cat = inline_t::cast vector_of_chars::cat : List(Vector) -> Vector;
keyed_apply = inline_t::cast vector_of_chars::keyed_apply: ((Int, Element) -> Void) -> Vector -> Void;
apply = inline_t::cast vector_of_chars::apply : (Element -> Void) -> Vector -> Void;
set = inline_t::cast vector_of_chars::set : (Vector, Int, Element) -> Vector;
keyed_map = inline_t::cast vector_of_chars::keyed_map : ((Int, Element) -> Element) -> Vector -> Vector;
(_[]:=) = set;
map = inline_t::cast vector_of_chars::map : (Element -> Element) -> Vector -> Vector;
v2cv = inline_t::cast : Vector -> vector_of_chars::Vector;
fun keyed_fold_forward f init vec
=
fold (0, init)
where
len = length vec;
#
fun fold (i, a)
=
if (i >= len) a;
else fold (i +++ 1, f (i, unsafe_get (vec, i), a));
fi;
end;
fun fold_forward f init vec
=
fold (0, init)
where
len = length vec;
#
fun fold (i, a)
=
if (i >= len) a;
else fold (i +++ 1, f (unsafe_get (vec, i), a));
fi;
end;
fun keyed_fold_backward f init vec
=
fold (length vec --- 1, init)
where
fun fold (i, a)
=
if (i < 0) a;
else fold (i --- 1, f (i, unsafe_get (vec, i), a));
fi;
end;
fun fold_backward f init vec
=
fold (length vec --- 1, init)
where
fun fold (i, a)
=
if (i < 0) a;
else fold (i --- 1, f (unsafe_get (vec, i), a));
fi;
end;
keyed_find = inline_t::cast vector_of_chars::keyed_find : ((Int, Element) -> Bool) -> Vector -> Null_Or( (Int, Element) );
find = inline_t::cast vector_of_chars::find : (Element -> Bool) -> Vector -> Null_Or( Element );
exists = inline_t::cast vector_of_chars::exists : (Element -> Bool) -> Vector -> Bool;
all = inline_t::cast vector_of_chars::all : (Element -> Bool) -> Vector -> Bool;
compare_sequences = inline_t::cast vector_of_chars::compare_sequences : ((Element, Element) -> Order) -> (Vector, Vector) -> Order;
};