Package components.standard
Interface Standard<T>
- Type Parameters:
T- type with these methods
- All Known Subinterfaces:
AMPMClock,BinaryTree<T>,BinaryTreeKernel<T>,List<T>,ListKernel<T>,Map<K,,V> MapKernel<K,,V> NaturalNumber,NaturalNumberKernel,Program,ProgramKernel,Queue<T>,QueueKernel<T>,Sequence<T>,SequenceKernel<T>,Set<T>,SetKernel<T>,SimpleReader,SimpleReaderKernel,SimpleWriter,SimpleWriterKernel,SortingMachine<T>,SortingMachineKernel<T>,Stack<T>,StackKernel<T>,Statement,StatementKernel,Stopwatch,Tree<T>,TreeKernel<T>
- All Known Implementing Classes:
BinaryTree1,BinaryTreeSecondary,List1L,List2,List3,ListSecondary,Map1L,Map2,Map3,Map4,MapSecondary,NaturalNumber1L,NaturalNumber2,NaturalNumber3,NaturalNumber4,NaturalNumberSecondary,Program1,ProgramSecondary,Queue1L,Queue2,Queue3,QueueSecondary,Sequence1L,Sequence2L,Sequence3,SequenceSecondary,Set1L,Set2,Set3,Set4,SetSecondary,SimpleReader1L,SimpleReaderSecondary,SimpleWriter1L,SimpleWriterSecondary,SortingMachine1L,SortingMachine2,SortingMachine3,SortingMachine4,SortingMachine5,SortingMachineSecondary,Stack1L,Stack2,Stack3,StackSecondary,Statement1,StatementSecondary,Stopwatch1,Tree1,TreeSecondary
public interface Standard<T>
Interface for
newInstance, clear, and transferFrom
methods that are expected of every mutable type in the "components" type
families.
Each of the Standard methods results in some variable having "an
initial value" of its type. The meaning of this phrase, indeed the meaning of
the "clears" parameter mode in all contracts in the "components" type
families, is as follows. If the type T has a no-argument constructor,
then the initial value satisfies the contract of the no-argument constructor.
If the type does not have a no-argument constructor, then the initial value
satisfies the contract of the constructor call that was used to initialize
the variable whose old value is relevant in the contract of the method.-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Resetsthisto an initial value.Returns a new object with the same dynamic type asthis, having an initial value.voidtransferFrom(T source) Setsthisto the incoming value ofsource, and resetssourceto an initial value; the declaration notwithstanding, the dynamic type ofsourcemust be the same as the dynamic type ofthis.
-
Method Details
-
newInstance
T newInstance()Returns a new object with the same dynamic type asthis, having an initial value. If the typeThas a no-argument constructor, then the value of the new returned object satisfies the contract of the no-argument constructor forT. IfTdoes not have a no-argument constructor, then the value of the new returned object satisfies the contract of the constructor call that was used to initializethis.- Returns:
- new object "like"
thiswith an initial value - Ensures:
is_initial(newInstance)
-
clear
void clear()Resetsthisto an initial value. If the typeThas a no-argument constructor, thenthissatisfies the contract of the no-argument constructor forT. IfTdoes not have a no-argument constructor, thenthissatisfies the contract of the constructor call that was used to initialize#this.- Clears:
this
-
transferFrom
Setsthisto the incoming value ofsource, and resetssourceto an initial value; the declaration notwithstanding, the dynamic type ofsourcemust be the same as the dynamic type ofthis. If the typeThas a no-argument constructor, thensourcesatisfies the contract of the no-argument constructor forT. IfTdoes not have a no-argument constructor, thensourcesatisfies the contract of the constructor call that was used to initialize#source.- Parameters:
source- object whose value is to be transferred- Replaces:
this- Clears:
source- Ensures:
this = #source
-