:- ensure_loaded(typeops).
:- tap_interface.
/*****************************************************************
	container_application

        several predicates which use exported predicates of
        module container_access
*******************************************************************/ 

:- pred add_list_to_cont(list(entry(T)), container(T), container(T)).
:- pred search_entry(container(T), int, T).

:- import_type(container_access).

% ....

:- tap_interface_end.


%%%%  example of a Old-Section  %%%%

:- import_type(prolog_types).

:- import_pred(prolog_types,'='/2).
:- import_pred(prolog_meta, !/0).
:- import_pred(prolog_io, write/1).

:- import_pred(container_access).


:- type atom --> {X | atom(X)}.


:- pred add_list_to_cont(list(entry(T)), container(T), container(T)).

add_list_to_cont([], ContIn, ContOut) :- !,
	ContOut = ContIn.
add_list_to_cont([X|Xs], ContIn, ContOut) :-
	add_entry(X, ContIn, ContTmp),!,
	add_list_to_cont(Xs, ContTmp, ContOut).
add_list_to_cont([_|Xs], ContIn, ContOut) :-
	add_list_to_cont(Xs, ContIn, ContOut).




:- pred search_entry(container(T), int, T).

search_entry(Cont, Key, Value) :-
	get_first(Cont,First),
	search_entry2(Cont, Key, First, Value).


:- pred search_entry2(container(T), int, entry(T), T).

search_entry2(_Cont, Key, AktEntry, Value) :-
	Key-Value = AktEntry,!.
search_entry2(Cont, Key, AktEntry, Value) :-
	get_next(Cont, AktEntry, NextEntry),
	search_entry2(Cont, Key, NextEntry, Value).



% ....

?- new_container(New),
	add_list_to_cont([ 3-reinhold, 1-diplom, 4-kloos, 2-typical],
	                 New, Cont),
	search_entry(Cont,2,Value),
	write(Value).
