xref: /netbsd-src/external/gpl3/binutils/dist/gprofng/src/DbeLinkList.h (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1*cb63e24eSchristos /* Copyright (C) 2021-2024 Free Software Foundation, Inc.
24f645668Schristos    Contributed by Oracle.
34f645668Schristos 
44f645668Schristos    This file is part of GNU Binutils.
54f645668Schristos 
64f645668Schristos    This program is free software; you can redistribute it and/or modify
74f645668Schristos    it under the terms of the GNU General Public License as published by
84f645668Schristos    the Free Software Foundation; either version 3, or (at your option)
94f645668Schristos    any later version.
104f645668Schristos 
114f645668Schristos    This program is distributed in the hope that it will be useful,
124f645668Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
134f645668Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
144f645668Schristos    GNU General Public License for more details.
154f645668Schristos 
164f645668Schristos    You should have received a copy of the GNU General Public License
174f645668Schristos    along with this program; if not, write to the Free Software
184f645668Schristos    Foundation, 51 Franklin Street - Fifth Floor, Boston,
194f645668Schristos    MA 02110-1301, USA.  */
204f645668Schristos 
214f645668Schristos #ifndef _DbeLinkList_h
224f645668Schristos #define _DbeLinkList_h
234f645668Schristos 
244f645668Schristos template <typename ITEM> class DbeLinkList
254f645668Schristos {
264f645668Schristos public:
274f645668Schristos 
DbeLinkList(ITEM _item)284f645668Schristos   DbeLinkList (ITEM _item)
294f645668Schristos   {
304f645668Schristos     item = _item;
314f645668Schristos     next = NULL;
324f645668Schristos   };
334f645668Schristos 
~DbeLinkList()344f645668Schristos   ~DbeLinkList () { };
354f645668Schristos 
364f645668Schristos   ITEM
get_item()374f645668Schristos   get_item ()
384f645668Schristos   {
394f645668Schristos     return item;
404f645668Schristos   }
414f645668Schristos 
424f645668Schristos   DbeLinkList<ITEM> *
get_next()434f645668Schristos   get_next ()
444f645668Schristos   {
454f645668Schristos     return next;
464f645668Schristos   }
474f645668Schristos 
484f645668Schristos   void
set_next(DbeLinkList<ITEM> * p)494f645668Schristos   set_next (DbeLinkList<ITEM> *p)
504f645668Schristos   {
514f645668Schristos     next = p;
524f645668Schristos   }
534f645668Schristos 
544f645668Schristos   void
554f645668Schristos   destroy (bool deleteItem = false)
564f645668Schristos   {
574f645668Schristos     for (DbeLinkList<ITEM> *p = next; p;)
584f645668Schristos       {
594f645668Schristos 	DbeLinkList<ITEM> *p1 = p->get_next ();
604f645668Schristos 	if (deleteItem)
614f645668Schristos 	  delete p->get_item ();
624f645668Schristos 	delete p;
634f645668Schristos 	p = p1;
644f645668Schristos       }
654f645668Schristos     next = NULL;
664f645668Schristos   }
674f645668Schristos 
684f645668Schristos private:
694f645668Schristos   ITEM item;
704f645668Schristos   DbeLinkList<ITEM> *next;
714f645668Schristos };
724f645668Schristos 
734f645668Schristos #endif /* _DbeLinkList_h */
74