13229Spst// -*- C++ -*- 23229Spst 33229Spst// Copyright (C) 2005, 2006 Free Software Foundation, Inc. 43229Spst// 53229Spst// This file is part of the GNU ISO C++ Library. This library is free 63229Spst// software; you can redistribute it and/or modify it under the terms 73229Spst// of the GNU General Public License as published by the Free Software 83229Spst// Foundation; either version 2, or (at your option) any later 93229Spst// version. 103229Spst 113229Spst// This library is distributed in the hope that it will be useful, but 123229Spst// WITHOUT ANY WARRANTY; without even the implied warranty of 133229Spst// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 143229Spst// General Public License for more details. 153229Spst 163229Spst// You should have received a copy of the GNU General Public License 173229Spst// along with this library; see the file COPYING. If not, write to 183229Spst// the Free Software Foundation, 59 Temple Place - Suite 330, Boston, 193229Spst// MA 02111-1307, USA. 203229Spst 2118471Swosch// As a special exception, you may use this file as part of a free 2250476Speter// software library without restriction. Specifically, if other files 2318471Swosch// instantiate templates or use macros or inline functions from this 243229Spst// file, or you compile this file and link it with other files to 253229Spst// produce an executable, this file does not by itself cause the 263229Spst// resulting executable to be covered by the GNU General Public 273229Spst// License. This exception does not however invalidate any other 283229Spst// reasons why the executable file might be covered by the GNU General 293229Spst// Public License. 303229Spst 313229Spst// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. 323229Spst 333229Spst// Permission to use, copy, modify, sell, and distribute this software 343229Spst// is hereby granted without fee, provided that the above copyright 353229Spst// notice appears in all copies, and that both that copyright notice 363229Spst// and this permission notice appear in supporting documentation. None 373229Spst// of the above authors, nor IBM Haifa Research Laboratories, make any 383229Spst// representation about the suitability of this software for any 393229Spst// purpose. It is provided "as is" without express or implied 403229Spst// warranty. 413229Spst 423229Spst/** 433229Spst * @file split_join_branch_bag.hpp 443229Spst * Contains an implementation class for pat_trie_. 453229Spst */ 463229Spst 473229Spstclass split_join_branch_bag 483229Spst{ 493229Spstprivate: 503229Spst typedef 5113575Spst std::list< 523229Spst internal_node_pointer, 533229Spst typename Allocator::template rebind< 543229Spst internal_node_pointer>::other> 553229Spst bag_t; 563229Spst 573229Spstpublic: 583229Spst 593229Spst void 6013575Spst add_branch() 613229Spst { 623229Spst internal_node_pointer p_nd = s_internal_node_allocator.allocate(1); 633229Spst try 643229Spst { 653229Spst m_bag.push_back(p_nd); 663229Spst } 673229Spst catch(...) 6869793Sobrien { 693229Spst s_internal_node_allocator.deallocate(p_nd, 1); 703229Spst __throw_exception_again; 713229Spst } 723229Spst } 733229Spst 743229Spst internal_node_pointer 753229Spst get_branch() 763229Spst { 773229Spst _GLIBCXX_DEBUG_ASSERT(!m_bag.empty()); 783229Spst internal_node_pointer p_nd =* m_bag.begin(); 793229Spst m_bag.pop_front(); 803229Spst return p_nd; 813229Spst } 823229Spst 833229Spst ~split_join_branch_bag() 843229Spst { 853229Spst while (!m_bag.empty()) 863229Spst { 873229Spst internal_node_pointer p_nd =* m_bag.begin(); 883229Spst s_internal_node_allocator.deallocate(p_nd, 1); 893229Spst m_bag.pop_front(); 903229Spst } 913229Spst } 923229Spst 933229Spst inline bool 943229Spst empty() const 953229Spst { return m_bag.empty(); } 963229Spst 973229Spstprivate: 983229Spst bag_t m_bag; 993229Spst}; 1003229Spst