Re: How to properly clean up an extended, generic structure?
- From: "Jeffrey R. Carter" <spam.not.jrcarter@xxxxxxxxxxxxxxxx>
- Date: Sun, 09 Jul 2006 19:46:01 GMT
Peter C. Chapin wrote:
Right now I'm working on a generic package that implements splay trees. My generic parameters look like:
generic
type Item_Type is private;
with function "<"(L : Item_Type; R : Item_Type) return Boolean;
package Splay_Tree is ...
Let me summarize the answers you've received, since some of them only address part of your concern.
Your tree should clean up after itself. You don't say if Splay_Tree provides ADTs or an ASM, but in either case controlled types are the way to achieve this (ARM 7.6). Then you don't need to have a visible Destroy operation, and the clients of your package aren't responsible for destroying a tree when it's no longer needed.
It's up to the clients of your package to arrange for finalization for the actual associated with Item_Type, if it's needed. Basically, if the actual needs finalization, then it should be a controlled type. If it's a controlled type, then its Finalization procedure will be called when an object ceases to exist, including due to deallocation.
--
Jeff Carter
"My mind is a raging torrent, flooded with rivulets of
thought, cascading into a waterfall of creative alternatives."
Blazing Saddles
89
.
- Follow-Ups:
- Re: How to properly clean up an extended, generic structure?
- From: Jean-Pierre Rosen
- Re: How to properly clean up an extended, generic structure?
- References:
- How to properly clean up an extended, generic structure?
- From: Peter C. Chapin
- How to properly clean up an extended, generic structure?
- Prev by Date: Re: How to properly clean up an extended, generic structure?
- Next by Date: Re: How to properly clean up an extended, generic structure?
- Previous by thread: Re: How to properly clean up an extended, generic structure?
- Next by thread: Re: How to properly clean up an extended, generic structure?
- Index(es):
Relevant Pages
|
|