mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-29 02:22:43 +00:00
Virgin import of GCC 2.95.1's libstdc++
This commit is contained in:
parent
b50366c383
commit
7b57a2734b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/gcc/dist/; revision=52277
@ -1,17 +1,272 @@
|
||||
Sun Mar 14 02:38:07 PST 1999 Jeff Law (law@cygnus.com)
|
||||
Mon Aug 16 01:29:24 PDT 1999 Jeff Law (law@cygnus.com)
|
||||
|
||||
* egcs-1.1.2 Released.
|
||||
* gcc-2.95.1 Released.
|
||||
|
||||
Thu Feb 25 02:21:22 1999 Jeffrey A Law (law@cygnus.com)
|
||||
Thu Aug 5 02:00:13 1999 Loren Rittle <ljrittle@acm.org>
|
||||
|
||||
* Makefile.in (MARLINK, MSHLINK): Handle library version
|
||||
number components with more than one numeric digit.
|
||||
|
||||
Mon Aug 2 00:40:10 1999 Jeffrey A Law (law@cygnus.com)
|
||||
|
||||
1999-07-16 Markus Gyger (mgyger@gmu.edu)
|
||||
* stdexcepti.cc (__out_of_range): Use std:: qualifier for names
|
||||
in std.
|
||||
(__length_error): Likewise.
|
||||
|
||||
Wed Jul 28 21:39:31 PDT 1999 Jeff Law (law@cygnus.com)
|
||||
|
||||
* gcc-2.95 Released.
|
||||
|
||||
Sun Jul 25 23:40:51 PDT 1999 Jeff Law (law@cygnus.com)
|
||||
|
||||
* gcc-2.95 Released.
|
||||
|
||||
Sat Jul 17 23:49:59 1999 Jeffrey A Law (law@cygnus.com)
|
||||
|
||||
* Makefile.in (INTERFACE): Bump to 3.
|
||||
|
||||
Fri Jul 9 01:20:23 1999 Jeffrey A Law (law@cygnus.com)
|
||||
|
||||
* Makefile.in (VERSION): Bump to 2.10.0.
|
||||
|
||||
Tue Jun 8 00:21:11 1999 Jeffrey A Law (law@cygnus.com)
|
||||
|
||||
* configure.in (*-*-freebsd2*): Add missing '*' at end of configure
|
||||
string.
|
||||
|
||||
1999-06-05 Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
|
||||
|
||||
* std/std_valarray.h: Don't #include unconditionally <alloca.h>
|
||||
|
||||
1999-06-05 Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
|
||||
|
||||
* std/std_valarray.h: New file.
|
||||
* std/slice.h: New file.
|
||||
* std/slice_array.h: New file.
|
||||
* std/gslice.h: New file.
|
||||
* std/gslice_array.h: New file.
|
||||
* std/mask_array.h: New file.
|
||||
* std/indirect_array.h: New file.
|
||||
* std/valarray_array.h: New file.
|
||||
* std/valarray_array.tcc: New file.
|
||||
* std/valarray_meta.h: New file.
|
||||
* valarray.cc: New file.
|
||||
* valarray: New file
|
||||
|
||||
* Makefile.in (OBJS): add valarray.o
|
||||
(HEADERS): add valarray
|
||||
(valarray.o): define dependency on valarray.cc
|
||||
(install): make it possible to install valarray file.
|
||||
|
||||
Wed Jun 2 00:21:54 1999 Robert Lipe <robertlipe@usa.net>
|
||||
|
||||
* std/bastring.h (class basic_string:Rep): Encode xlock opcode
|
||||
as .bytes instead of mnemonics.
|
||||
|
||||
1999-05-20 Angela Marie Thomas <angela@cygnus.com>
|
||||
|
||||
* configure.in: Test for ${compiler_name}.exe as well.
|
||||
|
||||
1999-05-15 Mark Kettenis <kettenis@gnu.org>
|
||||
|
||||
* configure.in: Add shared library support for the Hurd
|
||||
(*-*-gnu*).
|
||||
* config/gnu.ml: New file.
|
||||
|
||||
1999-05-12 Jason Merrill <jason@yorick.cygnus.com>
|
||||
|
||||
* configure.in (compiler_name): Don't do the skip-this-dir thing
|
||||
if we're reconfiguring.
|
||||
|
||||
1999-05-07 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* std/bastring.h (class basic_string::Rep): Make release member
|
||||
function thread-safe for ix86 (x>=4) and UltraSPARC.
|
||||
|
||||
* stlinst.cc: Make it possible to compile with __USE_MALLOC.
|
||||
|
||||
Mon Apr 26 02:24:47 1999 "Loren J. Rittle" <rittle@supra.rsch.comm.mot.com>
|
||||
|
||||
* config/freebsd.ml (LIBS): Add ARLINK.
|
||||
* config/openbsd.ml (LIBS): Add ARLINK.
|
||||
|
||||
Fri Apr 2 15:12:14 1999 H.J. Lu (hjl@gnu.org)
|
||||
|
||||
* libstdc++/configure.in (gxx_include_dir): Handle it.
|
||||
* libstdc++/Makefile.in: Likewise.
|
||||
|
||||
Wed Mar 24 22:36:45 1999 Mumit Khan <khan@xraylith.wisc.edu>
|
||||
|
||||
* configure.in (EXEEXT): Define.
|
||||
(compiler_name): Use.
|
||||
|
||||
Thu Mar 11 01:07:55 1999 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
|
||||
|
||||
* configure.in: Add mh-*pic handling for alpha, arm, powerpc
|
||||
|
||||
Fri Mar 5 02:16:39 1999 Doug Rabson <dfr@freebsd.org>
|
||||
|
||||
* configure.in: Support shared libs on FreeBSD 3.x and 4.x
|
||||
* config/freebsd.ml: A copy of config/linux.ml since they are both
|
||||
ELF and both have a shared libm.
|
||||
|
||||
1999-02-24 Jason Merrill <jason@yorick.cygnus.com>
|
||||
|
||||
* configure.in: Fix INSTALLDIR sed pattern for Solaris sed.
|
||||
|
||||
Sat Feb 20 13:17:17 1999 Jeffrey A Law (law@cygnus.com)
|
||||
|
||||
* string, std/straits.h, std/bastring.h: Revert recent change. Needs
|
||||
some libiberty support before it can be re-enabled.
|
||||
|
||||
Thu Feb 18 19:53:17 1999 Marc Espie <espie@cvs.openbsd.org>
|
||||
|
||||
Thu Feb 18 19:53:17 1999 Marc Espie <espie@cvs.openbsd.org>
|
||||
* configure.in: Handle OpenBSD with and without threads.
|
||||
* config/openbsd.ml: New file.
|
||||
* config/openbsd.mt: New file.
|
||||
|
||||
Mon Nov 23 09:44:26 1998 Richard Henderson <rth@cygnus.com>
|
||||
1999-02-04 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* configure.in: Append mh-ppcpic and mh-elfalphapic as appropriate.
|
||||
* configure.in: Recognize --enable-threads=posix for all
|
||||
platforms.
|
||||
* config/posix.mt: New file.
|
||||
|
||||
* configure.in: Add fragments for Solaris defining macro specifying
|
||||
thread library to be used.
|
||||
* config/sol2pth.mt: New file
|
||||
* config/sol2solth.mt: New file.
|
||||
* stl/stl_alloc.h: Add support for Solaris thread library.
|
||||
* stl/stl_config.h: Recognize _SOLTHREADS and define internal macros
|
||||
appropriately.
|
||||
|
||||
1999-01-28 Baron Roberts <baron@sgi.com>
|
||||
|
||||
* string: Uncomment wstring declaration.
|
||||
|
||||
* std/straits.h: Remove #if 0/#endif from around
|
||||
struct string_char_traits <wchar_t>.
|
||||
#include <cwchar>.
|
||||
Add missing definition for wchar_t move method.
|
||||
Add empty() method for trait-based empty string return.
|
||||
|
||||
* std/bastring.h (c_str): Change return of "" to return of
|
||||
traits::empty() call so that proper empty string is returned
|
||||
based on the character type (i.e. "" or L"").
|
||||
|
||||
1999-02-07 Jason Merrill <jason@yorick.cygnus.com>
|
||||
|
||||
* Makefile.in (stuff2): Tweak.
|
||||
|
||||
1999-02-04 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* configure.in: Recognize --enable-threads=posix for all
|
||||
platforms.
|
||||
* config/posix.mt: New file.
|
||||
|
||||
* configure.in: Add fragments for Solaris defining macro specifying
|
||||
thread library to be used.
|
||||
* config/sol2pth.mt: New file
|
||||
* config/sol2solth.mt: New file.
|
||||
* stl/stl_alloc.h: Add support for Solaris thread library.
|
||||
* stl/stl_config.h: Recognize _SOLTHREADS and define internal macros
|
||||
appropriately.
|
||||
|
||||
Sat Jan 30 08:05:46 1999 Mumit Khan <khan@xraylith.wisc.edu>
|
||||
|
||||
* config/x86-interix.ml: New file.
|
||||
* configure.in (i[3456]86-*-interix*): Add shared library support.
|
||||
|
||||
1999-01-13 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* configure.in: Test for "ln -s" and set LN_S in generated Makefile.
|
||||
* Makefile.in: Use $(LN_S) instead of explicitly ln -s.
|
||||
|
||||
Sun Jan 03 03:16:02 1999 Robert Lipe <robertlipe@usa.net>
|
||||
|
||||
* configure.in: (*-*-sysv5, *-*-*udk*): Treat like sysv4.
|
||||
|
||||
Tue Dec 8 00:59:09 1998 Marc Espie <Marc.Espie@liafa.jussieu.fr>
|
||||
|
||||
* Makefile.in: Be more selective about what files to install.
|
||||
|
||||
1998-11-30 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* std/bastring.cc (operator>>): Correct cast in last patch.
|
||||
(getline): Likewise.
|
||||
|
||||
1998-11-27 Alexandre Oliva <oliva@dcc.unicamp.br>
|
||||
|
||||
* Makefile.in (HEADERS): Install bitset.
|
||||
|
||||
1998-11-26 Manfred Hollstein <manfred@s-direktnet.de>
|
||||
|
||||
* configure.in (compiler_name): Add check to detect if this
|
||||
language's compiler has been built.
|
||||
|
||||
1998-11-23 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* std/bastring.cc (operator>>): Cast new character to char before
|
||||
adding to string.
|
||||
(getline): Likewise.
|
||||
|
||||
Thu Sep 17 01:29:46 1998 H.J. Lu (hjl@gnu.org)
|
||||
|
||||
* Makefile.in ($(ARLINK), $(SHLINK)): Don't rely on 'ln -f'.
|
||||
|
||||
* Makefile.in (install): Don't rely on 'ln -f'.
|
||||
|
||||
1998-09-09 Manfred Hollstein <manfred@s-direktnet.de>
|
||||
|
||||
* Makefile.in (install): Initialize RELINSTALLDIR correctly
|
||||
even for multilib and cross configurations.
|
||||
|
||||
* configure.in (INSTALLDIR): Don't change INSTALLDIR's init
|
||||
value if --enable-version-specific-runtime-libs has been specified.
|
||||
|
||||
Wed Sep 2 21:11:15 1998 H.J. Lu (hjl@gnu.org)
|
||||
|
||||
* Makefile.in (RELINSTALLDIR): New. Use it to make symlinks.
|
||||
|
||||
* configure.in: Fix INSTALLDIR replacement for cross-compile.
|
||||
|
||||
Sun Aug 30 22:17:41 1998 H.J. Lu (hjl@gnu.org)
|
||||
|
||||
* Makefile.in (INTERFACE): New, set to 2.
|
||||
(ARLIB): Set to libstdc++.a.$(VERSION)
|
||||
(ARLINK, MARLINK): New macros.
|
||||
(LIBS): Add $(ARLINK).
|
||||
($(ARLINK), marlink): New targets.
|
||||
(install): Don't check $(libsubdir). Handle versioned libraries.
|
||||
|
||||
* config/linux.ml (ARLIB, MARLINK, SHLIB, MSHLINK): New macros.
|
||||
(LIBS): Add marlink $(ARLINK).
|
||||
|
||||
* config/aix.ml (ARLIB): Set to libstdc++-ar.a.$(VERSION)
|
||||
(ARLINK): New macros.
|
||||
(BUILD_LIBS): Add $(ARLINK).
|
||||
|
||||
* config/dec-osf.ml (LIBS): Add $(ARLINK).
|
||||
* config/elf.ml (LIBS): Likewise.
|
||||
* config/elfshlibm.ml (LIBS): Likewise.
|
||||
* config/hpux.ml (LIBS): Likewise.
|
||||
* config/iris5.ml (LIBS): Likewise.
|
||||
* config/sol2shm.ml (LIBS): Likewise.
|
||||
* config/sunos4.ml (LIBS): Likewise.
|
||||
|
||||
* configure.in: Use ${topsrcdir}/config.if to put
|
||||
LIBSTDCXX_INTERFACE, CXX_INTERFACE, LIBC_INTERFACE in
|
||||
${package_makefile_frag}.
|
||||
|
||||
1998-08-25 Martin von Löwis <loewis@informatik.hu-berlin.de>
|
||||
|
||||
* stdexcept: Remove __HONOR_STD.
|
||||
|
||||
1998-08-23 Mark Mitchell <mark@markmitchell.com>
|
||||
|
||||
* sinst.cc: Don't explicitly instantiation string_char_traits<char>.
|
||||
* cinst.cc: Likewiwse, for complex<float>, complex<double>,
|
||||
complex<long double>.
|
||||
|
||||
1998-08-17 Mark Mitchell <mark@markmitchell.com>
|
||||
|
||||
@ -262,7 +517,7 @@ Tue Sep 9 19:47:07 1997 Jason Merrill <jason@yorick.cygnus.com>
|
||||
|
||||
Wed Aug 27 00:04:33 1997 Alexandre Oliva (oliva@dcc.unicamp.br)
|
||||
|
||||
* Makefile.in: create correct multiple links to
|
||||
* Makefile.in: Create correct multiple links to
|
||||
shared libstdc++.
|
||||
|
||||
Tue Aug 26 12:24:01 1997 H.J. Lu (hjl@gnu.ai.mit.edu)
|
||||
|
@ -14,9 +14,12 @@
|
||||
# along with this library; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
VERSION = 2.9.0
|
||||
VERSION = 2.10.0
|
||||
INTERFACE = 3
|
||||
|
||||
OBJS = cstringi.o stdexcepti.o cstdlibi.o cmathi.o stlinst.o
|
||||
gxx_include_dir=${includedir}/g++
|
||||
|
||||
OBJS = cstringi.o stdexcepti.o cstdlibi.o cmathi.o stlinst.o valarray.o
|
||||
SUBLIBS = $(STAMP)-string $(STAMP)-complx
|
||||
|
||||
# C++ headers with no extension
|
||||
@ -25,19 +28,21 @@ HEADERS= cassert cctype cerrno cfloat ciso646 climits clocale cmath complex \
|
||||
cwchar cwctype string stdexcept \
|
||||
algorithm deque functional hash_map hash_set iterator list map \
|
||||
memory numeric pthread_alloc queue rope set slist stack utility \
|
||||
vector fstream iomanip iostream strstream iosfwd
|
||||
vector fstream iomanip iostream strstream iosfwd bitset valarray
|
||||
|
||||
ARLIB = libstdc++.a
|
||||
ARLIB = libstdc++.a.$(VERSION)
|
||||
ARLINK = libstdc++.a
|
||||
MARLINK = libstdc++.a.`echo $(VERSION) | sed 's/\([0-9]*[.][0-9]*\).*/\1/'`
|
||||
SHLIB = libstdc++.so.$(VERSION)
|
||||
SHARLIB = libstdc++-sh.a
|
||||
SHLINK = libstdc++.so
|
||||
MSHLINK = libstdc++.so.`echo $(VERSION) | sed 's/\([0-9][.][0-9]\).*/\1/'`
|
||||
SHFLAGS =
|
||||
MSHLINK = libstdc++.so.`echo $(VERSION) | sed 's/\([0-9]*[.][0-9]*\).*/\1/'`
|
||||
SHFLAGS =
|
||||
SHDEPS =
|
||||
|
||||
STAMP = bigstmp
|
||||
|
||||
LIBS = $(ARLIB)
|
||||
LIBS = $(ARLIB) $(ARLINK)
|
||||
|
||||
#### package, host, target, and site dependent Makefile fragments come in here.
|
||||
##
|
||||
@ -85,6 +90,13 @@ $(ARLIB): stdlist
|
||||
mv t$(ARLIB) $(ARLIB)
|
||||
$(RANLIB) $(ARLIB)
|
||||
|
||||
$(ARLINK):
|
||||
-rm -f $(ARLINK)
|
||||
$(LN_S) $(ARLIB) $(ARLINK) || cp $(ARLIB) $(ARLINK)
|
||||
|
||||
marlink:
|
||||
@$(MAKE) $(MARLINK) "ARLINK=$(MARLINK)"
|
||||
|
||||
$(SHLIB): piclist
|
||||
$(CC) $(LIBCXXFLAGS) $(SHFLAGS) -shared -o $(SHLIB) `cat piclist` $(SHDEPS)
|
||||
|
||||
@ -95,7 +107,8 @@ $(SHARLIB): $(SHLIB)
|
||||
$(RANLIB) $(SHARLIB)
|
||||
|
||||
$(SHLINK):
|
||||
ln -f -s $(SHLIB) $(SHLINK)
|
||||
-rm -f $(SHLINK)
|
||||
$(LN_S) $(SHLIB) $(SHLINK) || cp $(ARLIB) $(ARLINK)
|
||||
|
||||
mshlink:
|
||||
@$(MAKE) $(MSHLINK) "SHLINK=$(MSHLINK)"
|
||||
@ -117,6 +130,7 @@ cstdlibi.o: cstdlibi.cc
|
||||
cmathi.o: cmathi.cc
|
||||
stdexcepti.o: stdexcepti.cc
|
||||
stlinst.o: stlinst.cc
|
||||
valarray.o: valarray.cc
|
||||
|
||||
# Later do wide strings, too.
|
||||
stmp-string: ${srcdir}/sinst.cc ${srcdir}/std/bastring.h \
|
||||
@ -256,7 +270,7 @@ install:
|
||||
fi ; \
|
||||
chmod a-x $(gxx_include_dir)/$$FILE ; \
|
||||
done ; \
|
||||
for FILE in *.h std/*.*; do \
|
||||
for FILE in *.h std/*.h std/*.cc std/*.tcc; do \
|
||||
rm -f $(gxx_include_dir)/$$FILE ; \
|
||||
$(INSTALL_DATA) $$FILE $(gxx_include_dir)/$$FILE ; \
|
||||
chmod a-x $(gxx_include_dir)/$$FILE ; \
|
||||
@ -270,20 +284,68 @@ install:
|
||||
else true ; \
|
||||
fi
|
||||
rootme=`pwd`/ ; export rootme ; \
|
||||
if [ x$(libsubdir) = x ] || [ x$(enable_version_specific_runtime_libs) != xyes ]; then \
|
||||
if [ x$(enable_version_specific_runtime_libs) != xyes ]; then \
|
||||
INSTALLDIR=$(libdir); \
|
||||
else \
|
||||
INSTALLDIR=$(libsubdir); \
|
||||
fi; \
|
||||
rm -f $${INSTALLDIR}$(MULTISUBDIR)/$(SHLINK) ; \
|
||||
INSTALLLINKDIR=$(libsubdir); \
|
||||
if [ $${INSTALLLINKDIR}$(MULTISUBDIR) = $${INSTALLDIR}$(MULTISUBDIR) ]; then \
|
||||
RELINSTALLDIR=; \
|
||||
elif [ x$(MULTISUBDIR) = x ]; then \
|
||||
if [ $(build_alias) = $(target_alias) ]; then \
|
||||
RELINSTALLDIR=../../../; \
|
||||
else \
|
||||
RELINSTALLDIR=../../../../$(target_alias)/lib/; \
|
||||
fi; \
|
||||
else \
|
||||
if [ $(build_alias) = $(target_alias) ]; then \
|
||||
RELINSTALLDIR=../../..`echo $(MULTISUBDIR) | sed -e 's,/[^/]*,/..,g'`$(MULTISUBDIR)/; \
|
||||
else \
|
||||
RELINSTALLDIR=../../../..`echo $(MULTISUBDIR) | sed -e 's,/[^/]*,/..,g'`/$(target_alias)/lib$(MULTISUBDIR)/; \
|
||||
fi; \
|
||||
fi; \
|
||||
if [ $(build_alias) != $(target_alias) ]; then \
|
||||
case $$RELINSTALLDIR in \
|
||||
../../../|../../../../) \
|
||||
RELINSTALLDIR=../$${RELINSTALLDIR}$(target_alias)/lib/;; \
|
||||
esac; \
|
||||
fi; \
|
||||
rm -f $${INSTALLLINKDIR}$(MULTISUBDIR)/$(SHLINK) ; \
|
||||
rm -f $${INSTALLLINKDIR}$(MULTISUBDIR)/$(ARLINK) ; \
|
||||
for FILE in $(LIBS) ; do \
|
||||
rm -f $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
if [ $$FILE = $(SHLINK) ] ; then \
|
||||
ln -f -s $(SHLIB) $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
if [ -f $${INSTALLDIR}/$(MSHLINK) ]; then \
|
||||
rm -f $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
$(LN_S) $${RELINSTALLDIR}$(MSHLINK) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE \
|
||||
|| cp $${RELINSTALLDIR}$(MSHLINK) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
else \
|
||||
rm -f $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
$(LN_S) $${RELINSTALLDIR}$(SHLIB) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE \
|
||||
|| cp $${RELINSTALLDIR}$(SHLIB) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
fi; \
|
||||
elif [ $$FILE = $(ARLINK) ] ; then \
|
||||
if [ -f $${INSTALLDIR}/$(MARLINK) ]; then \
|
||||
rm -f $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
$(LN_S) $${RELINSTALLDIR}$(MARLINK) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE \
|
||||
|| cp $${RELINSTALLDIR}$(MARLINK) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
else \
|
||||
rm -f $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
$(LN_S) $${RELINSTALLDIR}$(ARLIB) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE \
|
||||
|| cp $${RELINSTALLDIR}$(ARLIB) $${INSTALLLINKDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
fi; \
|
||||
elif [ $$FILE = mshlink ]; then \
|
||||
for FILE in $(MSHLINK) ; do \
|
||||
rm -f $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
ln -f -s $(SHLIB) $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
$(LN_S) $(SHLIB) $${INSTALLDIR}$(MULTISUBDIR)/$$FILE \
|
||||
|| cp $(SHLIB) $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
done; \
|
||||
elif [ $$FILE = marlink ]; then \
|
||||
for FILE in $(MARLINK) ; do \
|
||||
rm -f $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
$(LN_S) $(ARLIB) $${INSTALLDIR}$(MULTISUBDIR)/$$FILE \
|
||||
|| cp $(ARLIB) $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
done; \
|
||||
elif [ $$FILE = $(SHLIB) ]; then \
|
||||
$(INSTALL_PROGRAM) $$FILE $${INSTALLDIR}$(MULTISUBDIR)/$$FILE ; \
|
||||
@ -301,8 +363,7 @@ install:
|
||||
.PHONY: force
|
||||
force:
|
||||
|
||||
# Remove these for public releases.
|
||||
MYCXXFLAGS = -g -O2 -Wpointer-arith -Wnested-externs -Woverloaded-virtual -Wbad-function-cast -Winline -Wwrite-strings
|
||||
MYCXXFLAGS = -g -O2 -Wpointer-arith -Wnested-externs -Woverloaded-virtual -Wbad-function-cast -Winline -Wwrite-strings -pedantic -Wno-long-long
|
||||
MYCFLAGS = -g -O2 -Wpointer-arith -Wnested-externs
|
||||
|
||||
.PHONY: stuff
|
||||
@ -316,7 +377,8 @@ stuff1:
|
||||
touch ../../gcc/libgcc2.ready
|
||||
|
||||
stuff2:
|
||||
-$(MAKE) -C ../../gcc/ libgcc.a
|
||||
-$(MAKE) check CXXFLAGS="$(MYCXXFLAGS)" CFLAGS="$(MYCFLAGS)"
|
||||
$(MAKE) -C ../../gcc/ libgcc.a
|
||||
$(MAKE) CXXFLAGS="$(MYCXXFLAGS)" CFLAGS="$(MYCFLAGS)"
|
||||
-$(MAKE) check
|
||||
-$(MAKE) -C ../libio check
|
||||
-$(MAKE) -C ../../gcc check-g++
|
||||
|
@ -32,7 +32,6 @@ typedef complex<f> c;
|
||||
typedef const c& ccr;
|
||||
|
||||
#ifdef MAIN
|
||||
template class complex<f>;
|
||||
template c& __doapl (c*, ccr);
|
||||
template c& __doaml (c*, ccr);
|
||||
template c& __doami (c*, ccr);
|
||||
|
@ -1,8 +1,9 @@
|
||||
# AIX has wierd shared/non-shared libraries.
|
||||
|
||||
ARLIB = libstdc++-ar.a
|
||||
ARLIB = libstdc++-ar.a.$(VERSION)
|
||||
ARLINK = libstdc++-ar.a
|
||||
SHLINK = libstdc++.a
|
||||
LIBS = $(ARLIB) $(SHLIB) $(SHLINK)
|
||||
LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK)
|
||||
DEPLIBS = ../$(SHLIB)
|
||||
SHDEPS = -lm
|
||||
SHFLAGS = -Wl,-unix
|
||||
|
@ -1,6 +1,6 @@
|
||||
# We don't need -fpic on the alpha, so let's install both the shared and
|
||||
# non-shared versions.
|
||||
|
||||
LIBS = $(ARLIB) $(SHLIB) $(SHLINK)
|
||||
LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK)
|
||||
DEPLIBS = ../$(SHLIB)
|
||||
SHDEPS = -lm
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Elf without shared libm -- we have to link with the archive library, even
|
||||
# for programs that don't use complex.
|
||||
|
||||
LIBS = $(ARLIB) $(SHLIB) $(SHLINK)
|
||||
LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK)
|
||||
SHFLAGS = -h $(SHLIB)
|
||||
DEPLIBS = ../$(SHLIB)
|
||||
LDLIBS = -L.. -lstdc++ -lm
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Elf with shared libm, so we can link it into the shared libstdc++.
|
||||
|
||||
LIBS = $(ARLIB) $(SHLIB) $(SHLINK)
|
||||
LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK)
|
||||
SHFLAGS = -h $(SHLIB)
|
||||
SHDEPS = -lm
|
||||
DEPLIBS = ../$(SHLIB)
|
||||
|
6
contrib/libstdc++/config/freebsd.ml
Normal file
6
contrib/libstdc++/config/freebsd.ml
Normal file
@ -0,0 +1,6 @@
|
||||
# Elf with shared libm, so we can link it into the shared libstdc++.
|
||||
|
||||
LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK) mshlink
|
||||
SHFLAGS = -Wl,-soname,$(MSHLINK)
|
||||
SHDEPS = -lm
|
||||
DEPLIBS = ../$(SHLIB)
|
6
contrib/libstdc++/config/gnu.ml
Normal file
6
contrib/libstdc++/config/gnu.ml
Normal file
@ -0,0 +1,6 @@
|
||||
# Elf with shared libm, so we can link it into the shared libstdc++.
|
||||
|
||||
LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK)
|
||||
SHFLAGS = -Wl,-soname,$(SHLIB)
|
||||
SHDEPS = -lm
|
||||
DEPLIBS = ../$(SHLIB)
|
@ -1,6 +1,6 @@
|
||||
# HPUX uses the .sl suffix for shared libraries.
|
||||
|
||||
SHLIB = libstdc++.sl
|
||||
LIBS = $(ARLIB) $(SHLIB)
|
||||
LIBS = $(ARLIB) $(ARLINK) $(SHLIB)
|
||||
DEPLIBS = ../$(SHLIB)
|
||||
SHFLAGS = $(PICFLAG)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# We don't need -fpic on IRIX, so let's install both the shared and
|
||||
# non-shared versions.
|
||||
|
||||
LIBS = $(ARLIB) $(SHLIB) $(SHLINK)
|
||||
LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK)
|
||||
DEPLIBS = ../$(SHLIB)
|
||||
SHDEPS = -lm
|
||||
|
@ -1,6 +1,11 @@
|
||||
# Elf with shared libm, so we can link it into the shared libstdc++.
|
||||
|
||||
LIBS = $(ARLIB) $(SHLIB) $(SHLINK) mshlink
|
||||
ARLIB = libstdc++-$(LIBSTDCXX_INTERFACE)$(LIBC_INTERFACE)$(CXX_INTERFACE)-$(VERSION).a
|
||||
MARLINK = libstdc++$(LIBC_INTERFACE)$(CXX_INTERFACE).a.$(LIBSTDCXX_INTERFACE)
|
||||
SHLIB = libstdc++-$(LIBSTDCXX_INTERFACE)$(LIBC_INTERFACE)$(CXX_INTERFACE)-$(VERSION).so
|
||||
MSHLINK = libstdc++$(LIBC_INTERFACE)$(CXX_INTERFACE).so.$(LIBSTDCXX_INTERFACE)
|
||||
|
||||
LIBS = $(ARLIB) marlink $(ARLINK) $(SHLIB) mshlink $(SHLINK)
|
||||
SHFLAGS = -Wl,-soname,$(MSHLINK)
|
||||
SHDEPS = -lm
|
||||
DEPLIBS = ../$(SHLIB)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Base shared lib for OpenBSD i386
|
||||
|
||||
LIBS = $(ARLIB) $(SHLIB) $(SHLINK) mshlink
|
||||
LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK) mshlink
|
||||
SHFLAGS = -nostdlib -Wl,-Bshareable,-Bforcearchive
|
||||
SHDEPS = -lm
|
||||
DEPLIBS = ../$(SHLIB)
|
||||
|
1
contrib/libstdc++/config/posix.mt
Normal file
1
contrib/libstdc++/config/posix.mt
Normal file
@ -0,0 +1 @@
|
||||
MT_CFLAGS = -D_PTHREADS
|
1
contrib/libstdc++/config/sol2pth.mt
Normal file
1
contrib/libstdc++/config/sol2pth.mt
Normal file
@ -0,0 +1 @@
|
||||
MT_CFLAGS = -D_PTHREADS
|
@ -1,6 +1,6 @@
|
||||
# Solaris2 with shared libm, so we can link it into the shared libstdc++.
|
||||
|
||||
LIBS = $(ARLIB) $(SHLIB) $(SHLINK)
|
||||
LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK)
|
||||
SHFLAGS = -h $(SHLIB)
|
||||
SHDEPS = -lm
|
||||
DEPLIBS = ../$(SHLIB)
|
||||
|
1
contrib/libstdc++/config/sol2solth.mt
Normal file
1
contrib/libstdc++/config/sol2solth.mt
Normal file
@ -0,0 +1 @@
|
||||
MT_CFLAGS = -D_SOLTHREADS
|
@ -2,7 +2,7 @@
|
||||
# library, even for programs that don't use complex.
|
||||
# SunOS requires a version number in shared library filenames.
|
||||
|
||||
LIBS = $(ARLIB) $(SHLIB)
|
||||
LIBS = $(ARLIB) $(ARLINK) $(SHLIB)
|
||||
SHFLAGS = $(PICFLAG)
|
||||
DEPLIBS = ../$(SHLIB)
|
||||
LDLIBS = -L.. -lstdc++ -lm
|
||||
|
9
contrib/libstdc++/config/x86-interix.ml
Normal file
9
contrib/libstdc++/config/x86-interix.ml
Normal file
@ -0,0 +1,9 @@
|
||||
# x86 Interix. SHLINK is defined to be .dummy to avoid running into
|
||||
# the lack of symbolic links.
|
||||
|
||||
SHLINK = .dummy
|
||||
SHLIB = libstdc++.so
|
||||
LIBS = $(ARLIB) $(SHLIB)
|
||||
DEPLIBS = ../$(SHLIB)
|
||||
SHFLAGS = $(PICFLAG)
|
||||
|
@ -2,6 +2,25 @@
|
||||
# necessary for a configure script to process the program in
|
||||
# this directory. For more information, look at ../configure.
|
||||
|
||||
# If the language specific compiler does not exist, but the "gcc" directory
|
||||
# does, we do not build anything. Note, $r is set by the top-level Makefile.
|
||||
# Note that when we look for the compiler, we search both with and without
|
||||
# extension to handle cross and canadian cross builds.
|
||||
# Note that if $norecursion is set we're being called from config.status,
|
||||
# so don't check for the compiler; we might be doing a make clean.
|
||||
compiler_name=cc1plus
|
||||
rm -f skip-this-dir
|
||||
if test -n "$r" && [ -z "$norecursion" ] ; then
|
||||
if test -d "$r"/gcc; then
|
||||
if test -f "$r"/gcc/$compiler_name \
|
||||
|| test -f "$r"/gcc/$compiler_name.exe; then
|
||||
true
|
||||
else
|
||||
echo "rm -f multilib.out" > skip-this-dir
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${srcdir}" = "." ] ; then
|
||||
if [ "${with_target_subdir}" != "." ] ; then
|
||||
topsrcdir=${with_multisrctop}../..
|
||||
@ -39,14 +58,12 @@ esac
|
||||
|
||||
if [ "${shared}" = "yes" ]; then
|
||||
case "${target}" in
|
||||
alpha*-*-linux*) frags=../../config/mh-elfalphapic ;;
|
||||
arm*-*-*) frags=../../config/mh-armpic ;;
|
||||
hppa*-*-*) frags=../../config/mh-papic ;;
|
||||
i[3456]86-*-*) frags=../../config/mh-x86pic ;;
|
||||
alpha*-*-linux*) frags=../../config/mh-elfalphapic ;;
|
||||
|
||||
# There doesn't seem to be a simpler way to say all-ppc except AIX
|
||||
*-*-aix*) ;;
|
||||
powerpc*-* | ppc*-*) frags=../../config/mh-ppcpic ;;
|
||||
|
||||
powerpc*-*-aix*) ;;
|
||||
powerpc*-*-*) frags=../../config/mh-ppcpic ;;
|
||||
*-*-*) frags=../../config/mh-${target_cpu}pic ;;
|
||||
esac
|
||||
case "${target}" in
|
||||
@ -54,12 +71,16 @@ if [ "${shared}" = "yes" ]; then
|
||||
*-*-hpux*) frags="${frags} hpux.ml" ;;
|
||||
*-*-irix[56]*) frags="${frags} irix5.ml" ;;
|
||||
*-*-linux*aout*) ;;
|
||||
*-*-freebsd2*) ;;
|
||||
*-*-freebsd*) frags="${frags} freebsd.ml" ;;
|
||||
*-*-linux*) frags="${frags} linux.ml" ;;
|
||||
*-*-openbsd*) frags="${frags} openbsd.ml" ;;
|
||||
*-*-sysv4*) frags="${frags} elf.ml" ;;
|
||||
*-*-sysv[45]*|*-*-udk*) frags="${frags} elf.ml" ;;
|
||||
*-*-solaris*) frags="${frags} sol2shm.ml" ;;
|
||||
*-*-sunos4*) frags="${frags} sunos4.ml" ;;
|
||||
*-*-aix*) frags="${frags} aix.ml" ;;
|
||||
i[3456]86-*-interix*) frags="${frags} x86-interix.ml" ;;
|
||||
*-*-gnu*) frags="${frags} gnu.ml" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
@ -73,6 +94,15 @@ case "${target}" in
|
||||
xyes|xposix) frags="${frags} openbsd.mt" ;;
|
||||
esac;;
|
||||
m68k-motorola-sysv) frags="${frags} delta.mt" ;;
|
||||
*-*-solaris*)
|
||||
case "x${enable_threads}" in
|
||||
xposix) frags="${frags} sol2pth.mt" ;;
|
||||
xsolaris) frags="${frags} sol2solth.mt" ;;
|
||||
esac ;;
|
||||
*)
|
||||
case "x${enable_threads}" in
|
||||
xposix) frags="${frags} posix.mt" ;;
|
||||
esac ;;
|
||||
esac
|
||||
|
||||
for frag in ${frags}; do
|
||||
@ -105,15 +135,69 @@ EXTRA_DISTCLEAN='target-mkfrag'
|
||||
|
||||
(. ${srcdir}/${TO_TOPDIR}libio/config.shared) >${package_makefile_frag} 2>${package_makefile_rules_frag}
|
||||
|
||||
. ${topsrcdir}/config.if
|
||||
echo "
|
||||
LIBSTDCXX_INTERFACE=${libstdcxx_interface}
|
||||
CXX_INTERFACE=${cxx_interface}
|
||||
LIBC_INTERFACE=${libc_interface}
|
||||
" >> ${package_makefile_frag}
|
||||
|
||||
# This duplicated the AC_PROG_LN_S macro in GNU autoconf.
|
||||
rm -f conttestdata
|
||||
if ln -s X conftestdata 2>/dev/null
|
||||
then
|
||||
rm -f conftestdata
|
||||
LN_S="ln -s"
|
||||
else
|
||||
LN_S=ln
|
||||
fi
|
||||
echo "
|
||||
LN_S=$LN_S
|
||||
" >> ${package_makefile_frag}
|
||||
|
||||
# post-target:
|
||||
|
||||
# If cross-compiling, we install in $(tooldir).
|
||||
# If cross-compiling, we install in $(tooldir)/lib or in $(libsubdir)
|
||||
# depending on --enable-version-specific-runtime-libs.
|
||||
if [ -n "${with_cross_host}" ] ; then
|
||||
rm -f Makefile.tem
|
||||
sed \
|
||||
-e 's|\(INSTALLDIR[ ]*=[ ]*\)[^ ;]*|\1$(tooldir)/lib|' \
|
||||
-e 's|^\([ ]*INSTALLDIR[ ]*=[ ]*\)\$(libdir)|\1$(tooldir)/lib|' \
|
||||
Makefile >Makefile.tem
|
||||
mv -f Makefile.tem Makefile
|
||||
fi
|
||||
|
||||
# enable multilib-ing by default.
|
||||
if [ -z "${enable_multilib}" ]; then
|
||||
enable_multilib=yes
|
||||
fi
|
||||
|
||||
. ${topsrcdir}/config-ml.in
|
||||
|
||||
gxx_include_dir=
|
||||
# Specify the g++ header file directory
|
||||
# Check whether --with-gxx-include-dir or --without-gxx-include-dir was given.
|
||||
if test "${with_gxx_include_dir+set}" = set; then
|
||||
withval="$with_gxx_include_dir"
|
||||
case "${withval}" in
|
||||
yes)
|
||||
echo "configure.in: error: bad value ${withval} given for g++ include directory" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
no) ;;
|
||||
*) gxx_include_dir=$with_gxx_include_dir ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if test x${gxx_include_dir} = x; then
|
||||
if test x${enable_version_specific_runtime_libs} = xyes; then
|
||||
gxx_include_dir='${libsubdir}/include/g++'
|
||||
else
|
||||
gxx_include_dir='${prefix}/include/g++'-${libstdcxx_interface}
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f Makefile.tem
|
||||
sed -e "s%^gxx_include_dir[ ]*=.*$%gxx_include_dir=${gxx_include_dir}%" \
|
||||
Makefile >Makefile.tem
|
||||
mv -f Makefile.tem Makefile
|
||||
|
@ -42,8 +42,11 @@ typedef char c;
|
||||
typedef wchar_t c;
|
||||
#endif
|
||||
|
||||
#ifdef TRAITS
|
||||
#if defined(TRAITS) && !defined(C)
|
||||
template class string_char_traits <c>;
|
||||
#else
|
||||
/* string_char_traits<char> is already explicitly specialized in
|
||||
std/straits.h. */
|
||||
#endif
|
||||
|
||||
typedef basic_string <c> s;
|
||||
|
@ -39,7 +39,7 @@ operator delete (void * ptr)
|
||||
{
|
||||
Allocator::deallocate(ptr, sizeof(Rep) +
|
||||
reinterpret_cast<Rep *>(ptr)->res *
|
||||
sizeof (charT));
|
||||
sizeof (charT));
|
||||
}
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
@ -450,7 +450,7 @@ operator>> (istream &is, basic_string <charT, traits, Allocator> &s)
|
||||
sb->sungetc ();
|
||||
break;
|
||||
}
|
||||
s += ch;
|
||||
s += static_cast<charT> (ch);
|
||||
if (--w == 1)
|
||||
break;
|
||||
}
|
||||
@ -496,7 +496,7 @@ getline (istream &is, basic_string <charT, traits, Allocator>& s, charT delim)
|
||||
if (ch == delim)
|
||||
break;
|
||||
|
||||
s += ch;
|
||||
s += static_cast<charT> (ch);
|
||||
|
||||
if (s.length () == s.npos - 1)
|
||||
{
|
||||
|
@ -73,7 +73,41 @@ private:
|
||||
charT* data () { return reinterpret_cast<charT *>(this + 1); }
|
||||
charT& operator[] (size_t s) { return data () [s]; }
|
||||
charT* grab () { if (selfish) return clone (); ++ref; return data (); }
|
||||
#if defined __i486__ || defined __i586__ || defined __i686__
|
||||
void release ()
|
||||
{
|
||||
size_t __val;
|
||||
// This opcode exists as a .byte instead of as a mnemonic for the
|
||||
// benefit of SCO OpenServer 5. The system assembler (which is
|
||||
// essentially required on this target) can't assemble xaddl in
|
||||
//COFF mode.
|
||||
asm (".byte 0xf0, 0x0f, 0xc1, 0x02" // lock; xaddl %eax, (%edx)
|
||||
: "=a" (__val)
|
||||
: "0" (-1), "m" (ref), "d" (&ref)
|
||||
: "memory");
|
||||
|
||||
if (__val == 1)
|
||||
delete this;
|
||||
}
|
||||
#elif defined __sparcv9__
|
||||
void release ()
|
||||
{
|
||||
size_t __newval, __oldval = ref;
|
||||
do
|
||||
{
|
||||
__newval = __oldval - 1;
|
||||
__asm__ ("cas [%4], %2, %0"
|
||||
: "=r" (__oldval), "=m" (ref)
|
||||
: "r" (__oldval), "m" (ref), "r"(&(ref)), "0" (__newval));
|
||||
}
|
||||
while (__newval != __oldval);
|
||||
|
||||
if (__oldval == 0)
|
||||
delete this;
|
||||
}
|
||||
#else
|
||||
void release () { if (--ref == 0) delete this; }
|
||||
#endif
|
||||
|
||||
inline static void * operator new (size_t, size_t);
|
||||
inline static void operator delete (void *);
|
||||
|
111
contrib/libstdc++/std/gslice.h
Normal file
111
contrib/libstdc++/std/gslice.h
Normal file
@ -0,0 +1,111 @@
|
||||
// The template and inlines for the -*- C++ -*- gslice class.
|
||||
|
||||
// Copyright (C) 1997-1999 Cygnus Solutions
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
|
||||
|
||||
#ifndef __GSLICE__
|
||||
#define __GSLICE__
|
||||
|
||||
extern "C++" {
|
||||
|
||||
struct _Indexer {
|
||||
size_t _M_count;
|
||||
size_t _M_start;
|
||||
valarray<size_t> _M_size;
|
||||
valarray<size_t> _M_stride;
|
||||
valarray<size_t> _M_index;
|
||||
_Indexer(size_t, const valarray<size_t>&, const valarray<size_t>&);
|
||||
void _M_increment_use() { ++_M_count; }
|
||||
size_t _M_decrement_use() { return --_M_count; }
|
||||
};
|
||||
|
||||
|
||||
class gslice
|
||||
{
|
||||
public:
|
||||
gslice ();
|
||||
gslice (size_t, const valarray<size_t>&, const valarray<size_t>&);
|
||||
gslice(const gslice&);
|
||||
~gslice();
|
||||
|
||||
gslice& operator= (const gslice&);
|
||||
size_t start () const;
|
||||
valarray<size_t> size () const;
|
||||
valarray<size_t> stride () const;
|
||||
|
||||
private:
|
||||
_Indexer* _M_index;
|
||||
|
||||
template<typename _Tp> friend class valarray;
|
||||
};
|
||||
|
||||
inline size_t
|
||||
gslice::start () const
|
||||
{ return _M_index ? _M_index->_M_start : 0; }
|
||||
|
||||
inline valarray<size_t>
|
||||
gslice::size () const
|
||||
{ return _M_index ? _M_index->_M_size : valarray<size_t>(); }
|
||||
|
||||
inline valarray<size_t>
|
||||
gslice::stride () const
|
||||
{ return _M_index ? _M_index->_M_stride : valarray<size_t>(); }
|
||||
|
||||
inline gslice::gslice () : _M_index(0) {}
|
||||
|
||||
inline
|
||||
gslice::gslice(size_t __o, const valarray<size_t>& __l,
|
||||
const valarray<size_t>& __s)
|
||||
: _M_index(new _Indexer(__o, __l, __s)) {}
|
||||
|
||||
inline
|
||||
gslice::gslice(const gslice& __g) : _M_index(__g._M_index)
|
||||
{ if (_M_index) _M_index->_M_increment_use(); }
|
||||
|
||||
inline
|
||||
gslice::~gslice()
|
||||
{ if (_M_index && _M_index->_M_decrement_use() == 0) delete _M_index; }
|
||||
|
||||
inline gslice&
|
||||
gslice::operator= (const gslice& __g)
|
||||
{
|
||||
if (__g._M_index) __g._M_index->_M_increment_use();
|
||||
if (_M_index && _M_index->_M_decrement_use() == 0) delete _M_index;
|
||||
_M_index = __g._M_index;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
} // extern "C++"
|
||||
|
||||
#endif // __GSLICE__
|
||||
|
||||
// Local Variables:
|
||||
// mode:c++
|
||||
// End:
|
170
contrib/libstdc++/std/gslice_array.h
Normal file
170
contrib/libstdc++/std/gslice_array.h
Normal file
@ -0,0 +1,170 @@
|
||||
// The template and inlines for the -*- C++ -*- gslice_array class.
|
||||
|
||||
// Copyright (C) 1997-1999 Cygnus Solutions
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
|
||||
|
||||
#ifndef __GSLICE_ARRAY__
|
||||
#define __GSLICE_ARRAY__
|
||||
|
||||
extern "C++" {
|
||||
|
||||
template<typename _Tp> class gslice_array
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
|
||||
void operator= (const valarray<_Tp>&) const;
|
||||
void operator*= (const valarray<_Tp>&) const;
|
||||
void operator/= (const valarray<_Tp>&) const;
|
||||
void operator%= (const valarray<_Tp>&) const;
|
||||
void operator+= (const valarray<_Tp>&) const;
|
||||
void operator-= (const valarray<_Tp>&) const;
|
||||
void operator^= (const valarray<_Tp>&) const;
|
||||
void operator&= (const valarray<_Tp>&) const;
|
||||
void operator|= (const valarray<_Tp>&) const;
|
||||
void operator<<=(const valarray<_Tp>&) const;
|
||||
void operator>>=(const valarray<_Tp>&) const;
|
||||
void operator=(const _Tp&);
|
||||
|
||||
template<class _Dom>
|
||||
void operator= (const _Expr<_Dom,_Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator*= (const _Expr<_Dom,_Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator/= (const _Expr<_Dom,_Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator%= (const _Expr<_Dom,_Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator+= (const _Expr<_Dom,_Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator-= (const _Expr<_Dom,_Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator^= (const _Expr<_Dom,_Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator&= (const _Expr<_Dom,_Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator|= (const _Expr<_Dom,_Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator<<= (const _Expr<_Dom,_Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator>>= (const _Expr<_Dom,_Tp>&) const;
|
||||
|
||||
private:
|
||||
_Array<_Tp> _M_array;
|
||||
const valarray<size_t>& _M_index;
|
||||
|
||||
friend class valarray<_Tp>;
|
||||
|
||||
gslice_array (_Array<_Tp>, const valarray<size_t>&);
|
||||
|
||||
// this constructor needs to be implemented.
|
||||
gslice_array (const gslice_array&);
|
||||
|
||||
// not implemented
|
||||
gslice_array();
|
||||
gslice_array& operator= (const gslice_array&);
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
inline
|
||||
gslice_array<_Tp>::gslice_array (_Array<_Tp> __a,
|
||||
const valarray<size_t>& __i)
|
||||
: _M_array (__a), _M_index (__i) {}
|
||||
|
||||
|
||||
template<typename _Tp>
|
||||
inline
|
||||
gslice_array<_Tp>::gslice_array (const gslice_array<_Tp>& __a)
|
||||
: _M_array (__a._M_array), _M_index (__a._M_index) {}
|
||||
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
gslice_array<_Tp>::operator= (const _Tp& __t)
|
||||
{
|
||||
__valarray_fill (_M_array, _Array<size_t>(_M_index),
|
||||
_M_index.size(), __t);
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
gslice_array<_Tp>::operator= (const valarray<_Tp>& __v) const
|
||||
{
|
||||
__valarray_copy (_Array<_Tp> (__v), __v.size (),
|
||||
_M_array, _Array<size_t>(_M_index));
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
template<class E>
|
||||
inline void
|
||||
gslice_array<_Tp>::operator= (const _Expr<E, _Tp>& __e) const
|
||||
{
|
||||
__valarray_copy (__e, _M_index.size(), _M_array,
|
||||
_Array<size_t>(_M_index));
|
||||
}
|
||||
|
||||
#undef _DEFINE_VALARRAY_OPERATOR
|
||||
#define _DEFINE_VALARRAY_OPERATOR(op, name) \
|
||||
template<typename _Tp> \
|
||||
inline void \
|
||||
gslice_array<_Tp>::operator##op##= (const valarray<_Tp>& __v) const \
|
||||
{ \
|
||||
_Array_augmented_##name (_M_array, _Array<size_t>(_M_index), \
|
||||
_Array<_Tp> (__v), __v.size ()); \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp> template<class E> \
|
||||
inline void \
|
||||
gslice_array<_Tp>::operator##op##= (const _Expr<E, _Tp>& __e) const \
|
||||
{ \
|
||||
_Array_augmented_##name (_M_array, _Array<size_t>(_M_index), __e, \
|
||||
_M_index.size()); \
|
||||
}
|
||||
|
||||
_DEFINE_VALARRAY_OPERATOR(*, multiplies)
|
||||
_DEFINE_VALARRAY_OPERATOR(/, divides)
|
||||
_DEFINE_VALARRAY_OPERATOR(%, modulus)
|
||||
_DEFINE_VALARRAY_OPERATOR(+, plus)
|
||||
_DEFINE_VALARRAY_OPERATOR(-, minus)
|
||||
_DEFINE_VALARRAY_OPERATOR(^, xor)
|
||||
_DEFINE_VALARRAY_OPERATOR(&, and)
|
||||
_DEFINE_VALARRAY_OPERATOR(|, or)
|
||||
_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
|
||||
_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
|
||||
|
||||
#undef _DEFINE_VALARRAY_OPERATOR
|
||||
|
||||
} // extern "C++"
|
||||
|
||||
|
||||
#endif // __GSLICE_ARRAY__
|
||||
|
||||
// Local Variables:
|
||||
// mode:c++
|
||||
// End:
|
157
contrib/libstdc++/std/indirect_array.h
Normal file
157
contrib/libstdc++/std/indirect_array.h
Normal file
@ -0,0 +1,157 @@
|
||||
// The template and inlines for the -*- C++ -*- indirect_array class.
|
||||
|
||||
// Copyright (C) 1997-1999 Cygnus Solutions
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
|
||||
|
||||
#ifndef __INDIRECT_ARRAY__
|
||||
#define __INDIRECT_ARRAY__
|
||||
|
||||
extern "C++" {
|
||||
|
||||
template <class _Tp> class indirect_array
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
|
||||
void operator= (const valarray<_Tp>&) const;
|
||||
void operator*= (const valarray<_Tp>&) const;
|
||||
void operator/= (const valarray<_Tp>&) const;
|
||||
void operator%= (const valarray<_Tp>&) const;
|
||||
void operator+= (const valarray<_Tp>&) const;
|
||||
void operator-= (const valarray<_Tp>&) const;
|
||||
void operator^= (const valarray<_Tp>&) const;
|
||||
void operator&= (const valarray<_Tp>&) const;
|
||||
void operator|= (const valarray<_Tp>&) const;
|
||||
void operator<<= (const valarray<_Tp>&) const;
|
||||
void operator>>= (const valarray<_Tp>&) const;
|
||||
void operator= (const _Tp&);
|
||||
|
||||
template<class _Dom>
|
||||
void operator= (const _Expr<_Dom, _Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator*= (const _Expr<_Dom, _Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator/= (const _Expr<_Dom, _Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator%= (const _Expr<_Dom, _Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator+= (const _Expr<_Dom, _Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator-= (const _Expr<_Dom, _Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator^= (const _Expr<_Dom, _Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator&= (const _Expr<_Dom, _Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator|= (const _Expr<_Dom, _Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator<<= (const _Expr<_Dom, _Tp>&) const;
|
||||
template<class _Dom>
|
||||
void operator>>= (const _Expr<_Dom, _Tp>&) const;
|
||||
|
||||
private:
|
||||
indirect_array (const indirect_array&);
|
||||
indirect_array (_Array<_Tp>, size_t, _Array<size_t>);
|
||||
|
||||
friend class valarray<_Tp>;
|
||||
friend class gslice_array<_Tp>;
|
||||
|
||||
const size_t _M_sz;
|
||||
const _Array<size_t> _M_index;
|
||||
const _Array<_Tp> _M_array;
|
||||
|
||||
// not implemented
|
||||
indirect_array ();
|
||||
indirect_array& operator= (const indirect_array&);
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
inline indirect_array<_Tp>::indirect_array(const indirect_array<_Tp>& __a)
|
||||
: _M_sz (__a._M_sz), _M_index (__a._M_index),
|
||||
_M_array (__a._M_array) {}
|
||||
|
||||
template<typename _Tp>
|
||||
inline
|
||||
indirect_array<_Tp>::indirect_array (_Array<_Tp> __a, size_t __s,
|
||||
_Array<size_t> __i)
|
||||
: _M_sz (__s), _M_index (__i), _M_array (__a) {}
|
||||
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
indirect_array<_Tp>::operator= (const _Tp& __t)
|
||||
{ __valarray_fill(_M_array, _M_index, _M_sz, __t); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
indirect_array<_Tp>::operator= (const valarray<_Tp>& __v) const
|
||||
{ __valarray_copy (_Array<_Tp> (__v), _M_sz, _M_array, _M_index); }
|
||||
|
||||
template<typename _Tp>
|
||||
template<class _Dom>
|
||||
inline void
|
||||
indirect_array<_Tp>::operator= (const _Expr<_Dom,_Tp>& __e) const
|
||||
{ __valarray_copy (__e, _M_sz, _M_array, _M_index); }
|
||||
|
||||
#undef _DEFINE_VALARRAY_OPERATOR
|
||||
#define _DEFINE_VALARRAY_OPERATOR(op, name) \
|
||||
template<typename _Tp> \
|
||||
inline void \
|
||||
indirect_array<_Tp>::operator##op##= (const valarray<_Tp>& __v) const \
|
||||
{ \
|
||||
_Array_augmented_##name (_M_array, _M_index, _Array<_Tp> (__v), _M_sz); \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp> template<class _Dom> \
|
||||
inline void \
|
||||
indirect_array<_Tp>::operator##op##= (const _Expr<_Dom,_Tp>& __e) const \
|
||||
{ \
|
||||
_Array_augmented_##name (_M_array, _M_index, __e, _M_sz); \
|
||||
}
|
||||
|
||||
_DEFINE_VALARRAY_OPERATOR(*, multiplies)
|
||||
_DEFINE_VALARRAY_OPERATOR(/, divides)
|
||||
_DEFINE_VALARRAY_OPERATOR(%, modulus)
|
||||
_DEFINE_VALARRAY_OPERATOR(+, plus)
|
||||
_DEFINE_VALARRAY_OPERATOR(-, minus)
|
||||
_DEFINE_VALARRAY_OPERATOR(^, xor)
|
||||
_DEFINE_VALARRAY_OPERATOR(&, and)
|
||||
_DEFINE_VALARRAY_OPERATOR(|, or)
|
||||
_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
|
||||
_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
|
||||
|
||||
#undef _DEFINE_VALARRAY_OPERATOR
|
||||
|
||||
} // extern "C++"
|
||||
|
||||
#endif // __INDIRECT_ARRAY__
|
||||
|
||||
// Local Variables:
|
||||
// mode:c++
|
||||
// End:
|
154
contrib/libstdc++/std/mask_array.h
Normal file
154
contrib/libstdc++/std/mask_array.h
Normal file
@ -0,0 +1,154 @@
|
||||
// The template and inlines for the -*- C++ -*- mask_array class.
|
||||
|
||||
// Copyright (C) 1997-1999 Cygnus Solutions
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
|
||||
|
||||
#ifndef __MASK_ARRAY__
|
||||
#define __MASK_ARRAY__
|
||||
|
||||
extern "C++" {
|
||||
|
||||
template <class _T> class mask_array
|
||||
{
|
||||
public:
|
||||
typedef _T value_type;
|
||||
|
||||
void operator= (const valarray<_T>&) const;
|
||||
void operator*= (const valarray<_T>&) const;
|
||||
void operator/= (const valarray<_T>&) const;
|
||||
void operator%= (const valarray<_T>&) const;
|
||||
void operator+= (const valarray<_T>&) const;
|
||||
void operator-= (const valarray<_T>&) const;
|
||||
void operator^= (const valarray<_T>&) const;
|
||||
void operator&= (const valarray<_T>&) const;
|
||||
void operator|= (const valarray<_T>&) const;
|
||||
void operator<<=(const valarray<_T>&) const;
|
||||
void operator>>=(const valarray<_T>&) const;
|
||||
void operator= (const _T&);
|
||||
|
||||
template<class _Dom>
|
||||
void operator= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator*= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator/= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator%= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator+= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator-= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator^= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator&= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator|= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator<<=(const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator>>=(const _Expr<_Dom,_T>&) const;
|
||||
|
||||
private:
|
||||
mask_array (_Array<_T>, size_t, _Array<bool>);
|
||||
friend class valarray<_T>;
|
||||
|
||||
const size_t _M_sz;
|
||||
const _Array<bool> _M_mask;
|
||||
const _Array<_T> _M_array;
|
||||
|
||||
mask_array (const mask_array&);
|
||||
|
||||
// not implemented
|
||||
mask_array ();
|
||||
mask_array& operator= (const mask_array&);
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
inline mask_array<_Tp>::mask_array (const mask_array<_Tp>& a)
|
||||
: _M_sz (a._M_sz), _M_mask (a._M_mask), _M_array (a._M_array) {}
|
||||
|
||||
template<typename _T>
|
||||
inline
|
||||
mask_array<_T>::mask_array (_Array<_T> __a, size_t __s, _Array<bool> __m)
|
||||
: _M_sz (__s), _M_mask (__m), _M_array (__a) {}
|
||||
|
||||
template<typename _T>
|
||||
inline void
|
||||
mask_array<_T>::operator= (const _T& __t)
|
||||
{ __valarray_fill (_M_array, _M_sz, _M_mask, __t); }
|
||||
|
||||
template<typename _T>
|
||||
inline void
|
||||
mask_array<_T>::operator= (const valarray<_T>& __v) const
|
||||
{ __valarray_copy (_Array<_T> (__v), __v.size (), _M_array, _M_mask); }
|
||||
|
||||
template<typename _T>
|
||||
template<class E>
|
||||
inline void
|
||||
mask_array<_T>::operator= (const _Expr<E, _T>& __e) const
|
||||
{ __valarray_copy (__e, __e.size (), _M_array, _M_mask); }
|
||||
|
||||
#undef _DEFINE_VALARRAY_OPERATOR
|
||||
#define _DEFINE_VALARRAY_OPERATOR(op, name) \
|
||||
template<typename _T> \
|
||||
inline void \
|
||||
mask_array<_T>::operator##op##= (const valarray<_T>& __v) const \
|
||||
{ \
|
||||
_Array_augmented_##name (_M_array, _M_mask, \
|
||||
_Array<_T> (__v), __v.size ()); \
|
||||
} \
|
||||
\
|
||||
template<typename _T> template<class E> \
|
||||
inline void \
|
||||
mask_array<_T>::operator##op##= (const _Expr<E, _T>& __e) const \
|
||||
{ \
|
||||
_Array_augmented_##name (_M_array, _M_mask, __e, __e.size ()); \
|
||||
}
|
||||
|
||||
_DEFINE_VALARRAY_OPERATOR(*, multiplies)
|
||||
_DEFINE_VALARRAY_OPERATOR(/, divides)
|
||||
_DEFINE_VALARRAY_OPERATOR(%, modulus)
|
||||
_DEFINE_VALARRAY_OPERATOR(+, plus)
|
||||
_DEFINE_VALARRAY_OPERATOR(-, minus)
|
||||
_DEFINE_VALARRAY_OPERATOR(^, xor)
|
||||
_DEFINE_VALARRAY_OPERATOR(&, and)
|
||||
_DEFINE_VALARRAY_OPERATOR(|, or)
|
||||
_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
|
||||
_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
|
||||
|
||||
#undef _DEFINE_VALARRAY_OPERATOR
|
||||
|
||||
} // extern "C++"
|
||||
|
||||
#endif // __MASK_ARRAY__
|
||||
|
||||
// Local Variables:
|
||||
// mode:c++
|
||||
// End:
|
76
contrib/libstdc++/std/slice.h
Normal file
76
contrib/libstdc++/std/slice.h
Normal file
@ -0,0 +1,76 @@
|
||||
// The template and inlines for the -*- C++ -*- slice class.
|
||||
|
||||
// Copyright (C) 1997-1999 Cygnus Solutions
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
|
||||
|
||||
#ifndef __SLICE__
|
||||
#define __SLICE__
|
||||
|
||||
extern "C++" {
|
||||
|
||||
class slice
|
||||
{
|
||||
public:
|
||||
slice ();
|
||||
slice (size_t, size_t, size_t);
|
||||
|
||||
size_t start () const;
|
||||
size_t size () const;
|
||||
size_t stride () const;
|
||||
|
||||
private:
|
||||
size_t _M_off; // offset
|
||||
size_t _M_sz; // size
|
||||
size_t _M_st; // stride unit
|
||||
};
|
||||
|
||||
inline slice::slice () {}
|
||||
|
||||
inline slice::slice (size_t __o, size_t __d, size_t __s)
|
||||
: _M_off (__o), _M_sz (__d), _M_st (__s) {}
|
||||
|
||||
inline size_t
|
||||
slice::start () const
|
||||
{ return _M_off; }
|
||||
|
||||
inline size_t
|
||||
slice::size () const
|
||||
{ return _M_sz; }
|
||||
|
||||
inline size_t
|
||||
slice::stride () const
|
||||
{ return _M_st; }
|
||||
|
||||
} // extern "C++"
|
||||
|
||||
#endif // __SLICE__
|
||||
|
||||
// Local Variables:
|
||||
// mode:c++
|
||||
// End:
|
156
contrib/libstdc++/std/slice_array.h
Normal file
156
contrib/libstdc++/std/slice_array.h
Normal file
@ -0,0 +1,156 @@
|
||||
// The template and inlines for the -*- C++ -*- slice_array class.
|
||||
|
||||
// Copyright (C) 1997-1999 Cygnus Solutions
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
|
||||
|
||||
#ifndef __SLICE_ARRAY__
|
||||
#define __SLICE_ARRAY__
|
||||
|
||||
extern "C++" {
|
||||
|
||||
template<typename _T>
|
||||
class slice_array
|
||||
{
|
||||
public:
|
||||
typedef _T value_type;
|
||||
|
||||
void operator= (const valarray<_T>&) const;
|
||||
void operator*= (const valarray<_T>&) const;
|
||||
void operator/= (const valarray<_T>&) const;
|
||||
void operator%= (const valarray<_T>&) const;
|
||||
void operator+= (const valarray<_T>&) const;
|
||||
void operator-= (const valarray<_T>&) const;
|
||||
void operator^= (const valarray<_T>&) const;
|
||||
void operator&= (const valarray<_T>&) const;
|
||||
void operator|= (const valarray<_T>&) const;
|
||||
void operator<<= (const valarray<_T>&) const;
|
||||
void operator>>= (const valarray<_T>&) const;
|
||||
void operator= (const _T &);
|
||||
|
||||
template<class _Dom>
|
||||
void operator= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator*= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator/= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator%= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator+= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator-= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator^= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator&= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator|= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator<<= (const _Expr<_Dom,_T>&) const;
|
||||
template<class _Dom>
|
||||
void operator>>= (const _Expr<_Dom,_T>&) const;
|
||||
|
||||
private:
|
||||
friend class valarray<_T>;
|
||||
slice_array(_Array<_T>, const slice&);
|
||||
|
||||
const size_t _M_sz;
|
||||
const size_t _M_stride;
|
||||
const _Array<_T> _M_array;
|
||||
|
||||
// this constructor is implemented since we need to return a value.
|
||||
slice_array (const slice_array&);
|
||||
|
||||
// not implemented
|
||||
slice_array ();
|
||||
slice_array& operator= (const slice_array&);
|
||||
};
|
||||
|
||||
template<typename _T>
|
||||
inline slice_array<_T>::slice_array (_Array<_T> __a, const slice& __s)
|
||||
: _M_sz (__s.size ()), _M_stride (__s.stride ()),
|
||||
_M_array (__a.begin () + __s.start ()) {}
|
||||
|
||||
template<typename _Tp>
|
||||
inline slice_array<_Tp>::slice_array(const slice_array<_Tp>& a)
|
||||
: _M_sz(a._M_sz), _M_stride(a._M_stride), _M_array(a._M_array) {}
|
||||
|
||||
template<typename _T>
|
||||
inline void
|
||||
slice_array<_T>::operator= (const _T& __t)
|
||||
{ __valarray_fill (_M_array, _M_sz, _M_stride, __t); }
|
||||
|
||||
template<typename _T>
|
||||
inline void
|
||||
slice_array<_T>::operator= (const valarray<_T>& __v) const
|
||||
{ __valarray_copy (_Array<_T> (__v), _M_array, _M_sz, _M_stride); }
|
||||
|
||||
template<typename _T>
|
||||
template<class _Dom>
|
||||
inline void
|
||||
slice_array<_T>::operator= (const _Expr<_Dom,_T>& __e) const
|
||||
{ __valarray_copy (__e, _M_sz, _M_array, _M_stride); }
|
||||
|
||||
#undef _DEFINE_VALARRAY_OPERATOR
|
||||
#define _DEFINE_VALARRAY_OPERATOR(op, name) \
|
||||
template<typename _T> \
|
||||
inline void \
|
||||
slice_array<_T>::operator##op##= (const valarray<_T>& __v) const \
|
||||
{ \
|
||||
_Array_augmented_##name (_M_array, _M_sz, _M_stride, _Array<_T> (__v));\
|
||||
} \
|
||||
\
|
||||
template<typename _T> template<class _Dom> \
|
||||
inline void \
|
||||
slice_array<_T>::operator##op##= (const _Expr<_Dom,_T>& __e) const \
|
||||
{ \
|
||||
_Array_augmented_##name (_M_array, _M_stride, __e, _M_sz); \
|
||||
}
|
||||
|
||||
|
||||
_DEFINE_VALARRAY_OPERATOR(*, multiplies)
|
||||
_DEFINE_VALARRAY_OPERATOR(/, divides)
|
||||
_DEFINE_VALARRAY_OPERATOR(%, modulus)
|
||||
_DEFINE_VALARRAY_OPERATOR(+, plus)
|
||||
_DEFINE_VALARRAY_OPERATOR(-, minus)
|
||||
_DEFINE_VALARRAY_OPERATOR(^, xor)
|
||||
_DEFINE_VALARRAY_OPERATOR(&, and)
|
||||
_DEFINE_VALARRAY_OPERATOR(|, or)
|
||||
_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
|
||||
_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
|
||||
|
||||
#undef _DEFINE_VALARRAY_OPERATOR
|
||||
|
||||
} // extern "C++"
|
||||
|
||||
#endif // __SLICE_ARRAY__
|
||||
|
||||
// Local Variables:
|
||||
// mode:c++
|
||||
// End:
|
728
contrib/libstdc++/std/std_valarray.h
Normal file
728
contrib/libstdc++/std/std_valarray.h
Normal file
@ -0,0 +1,728 @@
|
||||
// The template and inlines for the -*- C++ -*- valarray class.
|
||||
|
||||
// Copyright (C) 1997-1999 Cygnus Solutions
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
|
||||
|
||||
#ifndef __STD_VALARRAY__
|
||||
#define __STD_VALARRAY__
|
||||
#define _G_NO_VALARRAY_TEMPLATE_EXPORT 1
|
||||
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <numeric>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
|
||||
#ifndef alloca
|
||||
#ifdef __GNUC__
|
||||
#define alloca __builtin_alloca
|
||||
#else /* not GNU C. */
|
||||
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
|
||||
#include <alloca.h>
|
||||
#else /* not sparc */
|
||||
#if defined (MSDOS) && !defined (__TURBOC__)
|
||||
#include <malloc.h>
|
||||
#else /* not MSDOS, or __TURBOC__ */
|
||||
#if defined(_AIX)
|
||||
#include <malloc.h>
|
||||
#pragma alloca
|
||||
#else /* not MSDOS, __TURBOC__, or _AIX */
|
||||
#ifdef __hpux
|
||||
#endif /* __hpux */
|
||||
#endif /* not _AIX */
|
||||
#endif /* not MSDOS, or __TURBOC__ */
|
||||
#endif /* not sparc. */
|
||||
#endif /* not GNU C. */
|
||||
#endif /* alloca not defined. */
|
||||
|
||||
extern "C" {
|
||||
void* alloca(size_t);
|
||||
}
|
||||
|
||||
|
||||
extern "C++" {
|
||||
|
||||
template<class _Clos, typename _Tp> class _Expr;
|
||||
|
||||
template<typename _Tp1, typename _Tp2> class _ValArray;
|
||||
|
||||
template<template<class> class _Oper,
|
||||
template<class, class> class _Meta, class _Dom> struct _UnClos;
|
||||
|
||||
template<template<class> class _Oper,
|
||||
template<class, class> class _Meta1,
|
||||
template<class, class> class _Meta2,
|
||||
class _Dom1, class _Dom2> class _BinClos;
|
||||
|
||||
template<template<class, class> class _Meta, class _Dom> class _SClos;
|
||||
|
||||
template<template<class, class> class _Meta, class _Dom> class _GClos;
|
||||
|
||||
template<template<class, class> class _Meta, class _Dom> class _IClos;
|
||||
|
||||
template<template<class, class> class _Meta, class _Dom> class _ValFunClos;
|
||||
|
||||
template<template<class, class> class _Meta, class _Dom> class _RefFunClos;
|
||||
|
||||
template<class _Tp> struct _Unary_plus;
|
||||
template<class _Tp> struct _Bitwise_and;
|
||||
template<class _Tp> struct _Bitwise_or;
|
||||
template<class _Tp> struct _Bitwise_xor;
|
||||
template<class _Tp> struct _Bitwise_not;
|
||||
template<class _Tp> struct _Shift_left;
|
||||
template<class _Tp> struct _Shift_right;
|
||||
|
||||
template<class _Tp> class valarray; // An array of type _Tp
|
||||
class slice; // BLAS-like slice out of an array
|
||||
template<class _Tp> class slice_array;
|
||||
class gslice; // generalized slice out of an array
|
||||
template<class _Tp> class gslice_array;
|
||||
template<class _Tp> class mask_array; // masked array
|
||||
template<class _Tp> class indirect_array; // indirected array
|
||||
|
||||
} // extern "C++"
|
||||
|
||||
#include <std/valarray_array.h>
|
||||
#include <std/valarray_meta.h>
|
||||
|
||||
extern "C++" {
|
||||
|
||||
template<class _Tp> class valarray
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
|
||||
// _lib.valarray.cons_ construct/destroy:
|
||||
valarray();
|
||||
explicit valarray(size_t);
|
||||
valarray(const _Tp&, size_t);
|
||||
valarray(const _Tp* __restrict__, size_t);
|
||||
valarray(const valarray&);
|
||||
valarray(const slice_array<_Tp>&);
|
||||
valarray(const gslice_array<_Tp>&);
|
||||
valarray(const mask_array<_Tp>&);
|
||||
valarray(const indirect_array<_Tp>&);
|
||||
template<class _Dom>
|
||||
valarray(const _Expr<_Dom,_Tp>& __e);
|
||||
~valarray();
|
||||
|
||||
// _lib.valarray.assign_ assignment:
|
||||
valarray<_Tp>& operator=(const valarray<_Tp>&);
|
||||
valarray<_Tp>& operator=(const _Tp&);
|
||||
valarray<_Tp>& operator=(const slice_array<_Tp>&);
|
||||
valarray<_Tp>& operator=(const gslice_array<_Tp>&);
|
||||
valarray<_Tp>& operator=(const mask_array<_Tp>&);
|
||||
valarray<_Tp>& operator=(const indirect_array<_Tp>&);
|
||||
|
||||
template<class _Dom> valarray<_Tp>&
|
||||
operator= (const _Expr<_Dom,_Tp>&);
|
||||
|
||||
// _lib.valarray.access_ element access:
|
||||
_Tp operator[](size_t) const;
|
||||
_Tp& operator[](size_t);
|
||||
// _lib.valarray.sub_ subset operations:
|
||||
_Expr<_SClos<_ValArray,_Tp>, _Tp> operator[](slice) const;
|
||||
slice_array<_Tp> operator[](slice);
|
||||
_Expr<_GClos<_ValArray,_Tp>, _Tp> operator[](const gslice&) const;
|
||||
gslice_array<_Tp> operator[](const gslice&);
|
||||
valarray<_Tp> operator[](const valarray<bool>&) const;
|
||||
mask_array<_Tp> operator[](const valarray<bool>&);
|
||||
_Expr<_IClos<_ValArray, _Tp>, _Tp>
|
||||
operator[](const valarray<size_t>&) const;
|
||||
indirect_array<_Tp> operator[](const valarray<size_t>&);
|
||||
|
||||
// _lib.valarray.unary_ unary operators:
|
||||
_Expr<_UnClos<_Unary_plus,_ValArray,_Tp>,_Tp> operator+ () const;
|
||||
_Expr<_UnClos<negate,_ValArray,_Tp>,_Tp> operator- () const;
|
||||
_Expr<_UnClos<_Bitwise_not,_ValArray,_Tp>,_Tp> operator~ () const;
|
||||
_Expr<_UnClos<logical_not,_ValArray,_Tp>,bool> operator! () const;
|
||||
|
||||
// _lib.valarray.cassign_ computed assignment:
|
||||
valarray<_Tp>& operator*= (const _Tp&);
|
||||
valarray<_Tp>& operator/= (const _Tp&);
|
||||
valarray<_Tp>& operator%= (const _Tp&);
|
||||
valarray<_Tp>& operator+= (const _Tp&);
|
||||
valarray<_Tp>& operator-= (const _Tp&);
|
||||
valarray<_Tp>& operator^= (const _Tp&);
|
||||
valarray<_Tp>& operator&= (const _Tp&);
|
||||
valarray<_Tp>& operator|= (const _Tp&);
|
||||
valarray<_Tp>& operator<<=(const _Tp&);
|
||||
valarray<_Tp>& operator>>=(const _Tp&);
|
||||
valarray<_Tp>& operator*= (const valarray<_Tp>&);
|
||||
valarray<_Tp>& operator/= (const valarray<_Tp>&);
|
||||
valarray<_Tp>& operator%= (const valarray<_Tp>&);
|
||||
valarray<_Tp>& operator+= (const valarray<_Tp>&);
|
||||
valarray<_Tp>& operator-= (const valarray<_Tp>&);
|
||||
valarray<_Tp>& operator^= (const valarray<_Tp>&);
|
||||
valarray<_Tp>& operator|= (const valarray<_Tp>&);
|
||||
valarray<_Tp>& operator&= (const valarray<_Tp>&);
|
||||
valarray<_Tp>& operator<<=(const valarray<_Tp>&);
|
||||
valarray<_Tp>& operator>>=(const valarray<_Tp>&);
|
||||
|
||||
template<class _Dom>
|
||||
valarray<_Tp>& operator*= (const _Expr<_Dom,_Tp>&);
|
||||
template<class _Dom>
|
||||
valarray<_Tp>& operator/= (const _Expr<_Dom,_Tp>&);
|
||||
template<class _Dom>
|
||||
valarray<_Tp>& operator%= (const _Expr<_Dom,_Tp>&);
|
||||
template<class _Dom>
|
||||
valarray<_Tp>& operator+= (const _Expr<_Dom,_Tp>&);
|
||||
template<class _Dom>
|
||||
valarray<_Tp>& operator-= (const _Expr<_Dom,_Tp>&);
|
||||
template<class _Dom>
|
||||
valarray<_Tp>& operator^= (const _Expr<_Dom,_Tp>&);
|
||||
template<class _Dom>
|
||||
valarray<_Tp>& operator|= (const _Expr<_Dom,_Tp>&);
|
||||
template<class _Dom>
|
||||
valarray<_Tp>& operator&= (const _Expr<_Dom,_Tp>&);
|
||||
template<class _Dom>
|
||||
valarray<_Tp>& operator<<=(const _Expr<_Dom,_Tp>&);
|
||||
template<class _Dom>
|
||||
valarray<_Tp>& operator>>=(const _Expr<_Dom,_Tp>&);
|
||||
|
||||
|
||||
// _lib.valarray.members_ member functions:
|
||||
size_t size() const;
|
||||
_Tp sum() const;
|
||||
_Tp min() const;
|
||||
_Tp max() const;
|
||||
|
||||
// FIXME: Extension
|
||||
_Tp product () const;
|
||||
|
||||
valarray<_Tp> shift (int) const;
|
||||
valarray<_Tp> cshift(int) const;
|
||||
_Expr<_ValFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(_Tp)) const;
|
||||
_Expr<_RefFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(const _Tp&)) const;
|
||||
void resize(size_t __size, _Tp __c = _Tp());
|
||||
|
||||
private:
|
||||
size_t _M_size;
|
||||
_Tp* __restrict__ _M_data;
|
||||
|
||||
friend class _Array<_Tp>;
|
||||
};
|
||||
|
||||
|
||||
template<typename _Tp> struct _Unary_plus : unary_function<_Tp,_Tp> {
|
||||
_Tp operator() (const _Tp& __t) const { return __t; }
|
||||
};
|
||||
|
||||
template<typename _Tp> struct _Bitwise_and : binary_function<_Tp,_Tp,_Tp> {
|
||||
_Tp operator() (_Tp __x, _Tp __y) const { return __x & __y; }
|
||||
};
|
||||
|
||||
template<typename _Tp> struct _Bitwise_or : binary_function<_Tp,_Tp,_Tp> {
|
||||
_Tp operator() (_Tp __x, _Tp __y) const { return __x | __y; }
|
||||
};
|
||||
|
||||
template<typename _Tp> struct _Bitwise_xor : binary_function<_Tp,_Tp,_Tp> {
|
||||
_Tp operator() (_Tp __x, _Tp __y) const { return __x ^ __y; }
|
||||
};
|
||||
|
||||
template<typename _Tp> struct _Bitwise_not : unary_function<_Tp,_Tp> {
|
||||
_Tp operator() (_Tp __t) const { return ~__t; }
|
||||
};
|
||||
|
||||
template<typename _Tp> struct _Shift_left : unary_function<_Tp,_Tp> {
|
||||
_Tp operator() (_Tp __x, _Tp __y) const { return __x << __y; }
|
||||
};
|
||||
|
||||
template<typename _Tp> struct _Shift_right : unary_function<_Tp,_Tp> {
|
||||
_Tp operator() (_Tp __x, _Tp __y) const { return __x >> __y; }
|
||||
};
|
||||
|
||||
|
||||
template<typename _Tp>
|
||||
inline _Tp
|
||||
valarray<_Tp>::operator[] (size_t __i) const
|
||||
{ return _M_data[__i]; }
|
||||
|
||||
template<typename _Tp>
|
||||
inline _Tp&
|
||||
valarray<_Tp>::operator[] (size_t __i)
|
||||
{ return _M_data[__i]; }
|
||||
|
||||
} // extern "C++"
|
||||
|
||||
#include <std/slice.h>
|
||||
#include <std/slice_array.h>
|
||||
#include <std/gslice.h>
|
||||
#include <std/gslice_array.h>
|
||||
#include <std/mask_array.h>
|
||||
#include <std/indirect_array.h>
|
||||
|
||||
extern "C++" {
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>::valarray () : _M_size (0), _M_data (0) {}
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>::valarray (size_t __n)
|
||||
: _M_size (__n), _M_data (new _Tp[__n]) {}
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>::valarray (const _Tp& __t, size_t __n)
|
||||
: _M_size (__n), _M_data (new _Tp[__n])
|
||||
{ __valarray_fill (_M_data, _M_size, __t); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>::valarray (const _Tp* __restrict__ __pT, size_t __n)
|
||||
: _M_size (__n), _M_data (new _Tp[__n])
|
||||
{ __valarray_copy (__pT, __n, _M_data); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>::valarray (const valarray<_Tp>& __v)
|
||||
: _M_size (__v._M_size), _M_data (new _Tp[__v._M_size])
|
||||
{ __valarray_copy (__v._M_data, _M_size, _M_data); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>::valarray (const slice_array<_Tp>& __sa)
|
||||
: _M_size (__sa._M_sz), _M_data (new _Tp[__sa._M_sz])
|
||||
{ __valarray_copy (__sa._M_array, __sa._M_sz, __sa._M_stride,
|
||||
_Array<_Tp>(_M_data)); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>::valarray (const gslice_array<_Tp>& __ga)
|
||||
: _M_size (__ga._M_index.size()), _M_data (new _Tp[_M_size])
|
||||
{ __valarray_copy (__ga._M_array, _Array<size_t>(__ga._M_index),
|
||||
_Array<_Tp>(_M_data), _M_size); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>::valarray (const mask_array<_Tp>& __ma)
|
||||
: _M_size (__ma._M_sz), _M_data (new _Tp[__ma._M_sz])
|
||||
{ __valarray_copy (__ma._M_array, __ma._M_mask,
|
||||
_Array<_Tp>(_M_data), _M_size); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>::valarray (const indirect_array<_Tp>& __ia)
|
||||
: _M_size (__ia._M_sz), _M_data (new _Tp[__ia._M_sz])
|
||||
{ __valarray_copy (__ia._M_array, __ia._M_index,
|
||||
_Array<_Tp>(_M_data), _M_size); }
|
||||
|
||||
template<typename _Tp> template<class _Dom>
|
||||
inline valarray<_Tp>::valarray (const _Expr<_Dom, _Tp>& __e)
|
||||
: _M_size (__e.size ()), _M_data (new _Tp[_M_size])
|
||||
{ __valarray_copy (__e, _M_size, _Array<_Tp>(_M_data)); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>::~valarray () { delete[] _M_data; }
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>&
|
||||
valarray<_Tp>::operator= (const valarray<_Tp>& __v)
|
||||
{
|
||||
__valarray_copy(__v._M_data, _M_size, _M_data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>&
|
||||
valarray<_Tp>::operator= (const _Tp& __t)
|
||||
{
|
||||
__valarray_fill (_M_data, _M_size, __t);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>&
|
||||
valarray<_Tp>::operator= (const slice_array<_Tp>& __sa)
|
||||
{
|
||||
__valarray_copy (__sa._M_array, __sa._M_sz,
|
||||
__sa._M_stride, _Array<_Tp>(_M_data));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>&
|
||||
valarray<_Tp>::operator= (const gslice_array<_Tp>& __ga)
|
||||
{
|
||||
__valarray_copy (__ga._M_array, _Array<size_t>(__ga._M_index),
|
||||
_Array<_Tp>(_M_data), _M_size);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>&
|
||||
valarray<_Tp>::operator= (const mask_array<_Tp>& __ma)
|
||||
{
|
||||
__valarray_copy (__ma._M_array, __ma._M_mask,
|
||||
_Array<_Tp>(_M_data), _M_size);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>&
|
||||
valarray<_Tp>::operator= (const indirect_array<_Tp>& __ia)
|
||||
{
|
||||
__valarray_copy (__ia._M_array, __ia._M_index,
|
||||
_Array<_Tp>(_M_data), _M_size);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename _Tp> template<class _Dom>
|
||||
inline valarray<_Tp>&
|
||||
valarray<_Tp>::operator= (const _Expr<_Dom, _Tp>& __e)
|
||||
{
|
||||
__valarray_copy (__e, _M_size, _Array<_Tp>(_M_data));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline _Expr<_SClos<_ValArray,_Tp>, _Tp>
|
||||
valarray<_Tp>::operator[] (slice __s) const
|
||||
{
|
||||
typedef _SClos<_ValArray,_Tp> _Closure;
|
||||
return _Expr<_Closure, _Tp> (_Closure (_Array<_Tp>(_M_data), __s));
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline slice_array<_Tp>
|
||||
valarray<_Tp>::operator[] (slice __s)
|
||||
{
|
||||
return slice_array<_Tp> (_Array<_Tp>(_M_data), __s);
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline _Expr<_GClos<_ValArray,_Tp>, _Tp>
|
||||
valarray<_Tp>::operator[] (const gslice& __gs) const
|
||||
{
|
||||
typedef _GClos<_ValArray,_Tp> _Closure;
|
||||
return _Expr<_Closure, _Tp>
|
||||
(_Closure (_Array<_Tp>(_M_data), __gs._M_index->_M_index));
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline gslice_array<_Tp>
|
||||
valarray<_Tp>::operator[] (const gslice& __gs)
|
||||
{
|
||||
return gslice_array<_Tp>
|
||||
(_Array<_Tp>(_M_data), __gs._M_index->_M_index);
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline valarray<_Tp>
|
||||
valarray<_Tp>::operator[] (const valarray<bool>& __m) const
|
||||
{
|
||||
size_t __s (0);
|
||||
size_t __e (__m.size ());
|
||||
for (size_t __i=0; __i<__e; ++__i)
|
||||
if (__m[__i]) ++__s;
|
||||
return valarray<_Tp> (mask_array<_Tp> (_Array<_Tp>(_M_data), __s,
|
||||
_Array<bool> (__m)));
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline mask_array<_Tp>
|
||||
valarray<_Tp>::operator[] (const valarray<bool>& __m)
|
||||
{
|
||||
size_t __s (0);
|
||||
size_t __e (__m.size ());
|
||||
for (size_t __i=0; __i<__e; ++__i)
|
||||
if (__m[__i]) ++__s;
|
||||
return mask_array<_Tp> (_Array<_Tp>(_M_data), __s, _Array<bool> (__m));
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline _Expr<_IClos<_ValArray,_Tp>, _Tp>
|
||||
valarray<_Tp>::operator[] (const valarray<size_t>& __i) const
|
||||
{
|
||||
typedef _IClos<_ValArray,_Tp> _Closure;
|
||||
return _Expr<_Closure, _Tp> (_Closure (*this, __i));
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline indirect_array<_Tp>
|
||||
valarray<_Tp>::operator[] (const valarray<size_t>& __i)
|
||||
{
|
||||
return indirect_array<_Tp> (_Array<_Tp>(_M_data), __i.size(),
|
||||
_Array<size_t> (__i));
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
inline size_t valarray<_Tp>::size () const { return _M_size; }
|
||||
|
||||
template<class _Tp>
|
||||
inline _Tp
|
||||
valarray<_Tp>::sum () const
|
||||
{
|
||||
return accumulate (_M_data, _M_data + _M_size, _Tp ());
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline _Tp
|
||||
valarray<_Tp>::product () const
|
||||
{
|
||||
return accumulate (_M_data, _M_data+_M_size, _Tp(1), multiplies<_Tp> ());
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline valarray<_Tp>
|
||||
valarray<_Tp>::shift (int __n) const
|
||||
{
|
||||
_Tp* const __a = static_cast<_Tp*> (alloca (sizeof(_Tp) * _M_size));
|
||||
if (! __n) // __n == 0: no shift
|
||||
__valarray_copy (_M_data, _M_size, __a);
|
||||
else if (__n > 0) { // __n > 0: shift left
|
||||
if (__n > _M_size)
|
||||
__valarray_fill(__a, __n, _Tp());
|
||||
else {
|
||||
__valarray_copy (_M_data+__n, _M_size-__n, __a);
|
||||
__valarray_fill (__a+_M_size-__n, __n, _Tp());
|
||||
}
|
||||
}
|
||||
else { // __n < 0: shift right
|
||||
__valarray_copy (_M_data, _M_size+__n, __a-__n);
|
||||
__valarray_fill(__a, -__n, _Tp());
|
||||
}
|
||||
return valarray<_Tp> (__a, _M_size);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline valarray<_Tp>
|
||||
valarray<_Tp>::cshift (int __n) const
|
||||
{
|
||||
_Tp* const __a = static_cast<_Tp*> (alloca (sizeof(_Tp) * _M_size));
|
||||
if (! __n) // __n == 0: no cshift
|
||||
__valarray_copy(_M_data, _M_size, __a);
|
||||
else if (__n > 0) { // __n > 0: cshift left
|
||||
__valarray_copy (_M_data, __n, __a + _M_size-__n);
|
||||
__valarray_copy (_M_data + __n, _M_size-__n, __a);
|
||||
}
|
||||
else { // __n < 0: cshift right
|
||||
__valarray_copy (_M_data + _M_size + __n, -__n, __a);
|
||||
__valarray_copy (_M_data, _M_size + __n, __a - __n);
|
||||
}
|
||||
return valarray<_Tp> (__a, _M_size);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline void
|
||||
valarray<_Tp>::resize (size_t __n, _Tp __c)
|
||||
{
|
||||
if (_M_size != __n) {
|
||||
delete[] _M_data;
|
||||
_M_size = __n;
|
||||
_M_data = new _Tp[_M_size];
|
||||
}
|
||||
__valarray_fill (_M_data, _M_size, __c);
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline _Tp
|
||||
valarray<_Tp>::min() const
|
||||
{
|
||||
return *min_element (_M_data, _M_data+_M_size);
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline _Tp
|
||||
valarray<_Tp>::max() const
|
||||
{
|
||||
return *max_element (_M_data, _M_data+_M_size);
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
inline _Expr<_ValFunClos<_ValArray,_Tp>,_Tp>
|
||||
valarray<_Tp>::apply (_Tp func (_Tp)) const
|
||||
{
|
||||
typedef _ValFunClos<_ValArray,_Tp> _Closure;
|
||||
return _Expr<_Closure,_Tp> (_Closure (*this, func));
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
inline _Expr<_RefFunClos<_ValArray,_Tp>,_Tp>
|
||||
valarray<_Tp>::apply (_Tp func (const _Tp &)) const
|
||||
{
|
||||
typedef _RefFunClos<_ValArray,_Tp> _Closure;
|
||||
return _Expr<_Closure,_Tp> (_Closure (*this, func));
|
||||
}
|
||||
|
||||
#define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name) \
|
||||
template<typename _Tp> \
|
||||
inline _Expr<_UnClos<_Name,_ValArray,_Tp>, _Tp> \
|
||||
valarray<_Tp>::operator##_Op() const \
|
||||
{ \
|
||||
typedef _UnClos<_Name,_ValArray,_Tp> _Closure; \
|
||||
return _Expr<_Closure, _Tp> (_Closure (*this)); \
|
||||
}
|
||||
|
||||
_DEFINE_VALARRAY_UNARY_OPERATOR(+, _Unary_plus)
|
||||
_DEFINE_VALARRAY_UNARY_OPERATOR(-, negate)
|
||||
_DEFINE_VALARRAY_UNARY_OPERATOR(~, _Bitwise_not)
|
||||
|
||||
#undef _DEFINE_VALARRAY_UNARY_OPERATOR
|
||||
|
||||
template<typename _Tp>
|
||||
inline _Expr<_UnClos<logical_not,_ValArray,_Tp>, bool>
|
||||
valarray<_Tp>::operator!() const
|
||||
{
|
||||
typedef _UnClos<logical_not,_ValArray,_Tp> _Closure;
|
||||
return _Expr<_Closure, bool> (_Closure (*this));
|
||||
}
|
||||
|
||||
#define _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(_Op, _Name) \
|
||||
template<class _Tp> \
|
||||
inline valarray<_Tp> & \
|
||||
valarray<_Tp>::operator##_Op##= (const _Tp &__t) \
|
||||
{ \
|
||||
_Array_augmented_##_Name (_Array<_Tp>(_M_data), _M_size, __t); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
template<class _Tp> \
|
||||
inline valarray<_Tp> & \
|
||||
valarray<_Tp>::operator##_Op##= (const valarray<_Tp> &__v) \
|
||||
{ \
|
||||
_Array_augmented_##_Name (_Array<_Tp>(_M_data), _M_size, \
|
||||
_Array<_Tp>(__v._M_data)); \
|
||||
return *this; \
|
||||
}
|
||||
|
||||
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(+, plus)
|
||||
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(-, minus)
|
||||
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(*, multiplies)
|
||||
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(/, divides)
|
||||
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(%, modulus)
|
||||
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(^, xor)
|
||||
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(&, and)
|
||||
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(|, or)
|
||||
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(<<, shift_left)
|
||||
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, shift_right)
|
||||
|
||||
#undef _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT
|
||||
|
||||
|
||||
#define _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(_Op, _Name) \
|
||||
template<class _Tp> template<class _Dom> \
|
||||
inline valarray<_Tp> & \
|
||||
valarray<_Tp>::operator##_Op##= (const _Expr<_Dom,_Tp> &__e) \
|
||||
{ \
|
||||
_Array_augmented_##_Name (_Array<_Tp>(_M_data), __e, _M_size); \
|
||||
return *this; \
|
||||
}
|
||||
|
||||
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(+, plus)
|
||||
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(-, minus)
|
||||
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(*, multiplies)
|
||||
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(/, divides)
|
||||
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(%, modulus)
|
||||
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(^, xor)
|
||||
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(&, and)
|
||||
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(|, or)
|
||||
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(<<, shift_left)
|
||||
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, shift_right)
|
||||
|
||||
#undef _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT
|
||||
|
||||
|
||||
#define _DEFINE_BINARY_OPERATOR(_Op, _Name) \
|
||||
template<typename _Tp> \
|
||||
inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>, _Tp> \
|
||||
operator##_Op (const valarray<_Tp> &__v, const valarray<_Tp> &__w) \
|
||||
{ \
|
||||
typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \
|
||||
return _Expr<_Closure, _Tp> (_Closure (__v, __w)); \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp> \
|
||||
inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>,_Tp> \
|
||||
operator##_Op (const valarray<_Tp> &__v, const _Tp &__t) \
|
||||
{ \
|
||||
typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \
|
||||
return _Expr<_Closure, _Tp> (_Closure (__v, __t)); \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp> \
|
||||
inline _Expr<_BinClos<_Name,_Constant,_ValArray,_Tp,_Tp>,_Tp> \
|
||||
operator##_Op (const _Tp &__t, const valarray<_Tp> &__v) \
|
||||
{ \
|
||||
typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \
|
||||
return _Expr<_Closure, _Tp> (_Closure (__t, __v)); \
|
||||
}
|
||||
|
||||
_DEFINE_BINARY_OPERATOR(+, plus)
|
||||
_DEFINE_BINARY_OPERATOR(-, minus)
|
||||
_DEFINE_BINARY_OPERATOR(*, multiplies)
|
||||
_DEFINE_BINARY_OPERATOR(/, divides)
|
||||
_DEFINE_BINARY_OPERATOR(%, modulus)
|
||||
_DEFINE_BINARY_OPERATOR(^, _Bitwise_xor)
|
||||
_DEFINE_BINARY_OPERATOR(&, _Bitwise_and)
|
||||
_DEFINE_BINARY_OPERATOR(|, _Bitwise_or)
|
||||
_DEFINE_BINARY_OPERATOR(<<, _Shift_left)
|
||||
_DEFINE_BINARY_OPERATOR(>>, _Shift_right)
|
||||
|
||||
#undef _DEFINE_BINARY_OPERATOR
|
||||
|
||||
#define _DEFINE_LOGICAL_OPERATOR(_Op, _Name) \
|
||||
template<typename _Tp> \
|
||||
inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>,bool> \
|
||||
operator##_Op (const valarray<_Tp> &__v, const valarray<_Tp> &__w) \
|
||||
{ \
|
||||
typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \
|
||||
return _Expr<_Closure, bool> (_Closure (__v, __w)); \
|
||||
} \
|
||||
\
|
||||
template<class _Tp> \
|
||||
inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>,bool> \
|
||||
operator##_Op (const valarray<_Tp> &__v, const _Tp &__t) \
|
||||
{ \
|
||||
typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \
|
||||
return _Expr<_Closure, bool> (_Closure (__v, __t)); \
|
||||
} \
|
||||
\
|
||||
template<class _Tp> \
|
||||
inline _Expr<_BinClos<_Name,_Constant,_ValArray,_Tp,_Tp>,bool> \
|
||||
operator##_Op (const _Tp &__t, const valarray<_Tp> &__v) \
|
||||
{ \
|
||||
typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \
|
||||
return _Expr<_Closure, bool> (_Closure (__t, __v)); \
|
||||
}
|
||||
|
||||
_DEFINE_LOGICAL_OPERATOR(&&, logical_and)
|
||||
_DEFINE_LOGICAL_OPERATOR(||, logical_or)
|
||||
_DEFINE_LOGICAL_OPERATOR(==, equal_to)
|
||||
_DEFINE_LOGICAL_OPERATOR(!=, not_equal_to)
|
||||
_DEFINE_LOGICAL_OPERATOR(<, less)
|
||||
_DEFINE_LOGICAL_OPERATOR(>, greater)
|
||||
_DEFINE_LOGICAL_OPERATOR(<=, less_equal)
|
||||
_DEFINE_LOGICAL_OPERATOR(>=, greater_equal)
|
||||
|
||||
#undef _DEFINE_VALARRAY_OPERATOR
|
||||
|
||||
#undef _G_NO_VALARRAY_TEMPLATE_EXPORT
|
||||
|
||||
} // extern "C++"
|
||||
|
||||
#endif // __STD_VALARRAY__
|
||||
|
||||
// Local Variables:
|
||||
// mode:c++
|
||||
// End:
|
346
contrib/libstdc++/std/valarray_array.h
Normal file
346
contrib/libstdc++/std/valarray_array.h
Normal file
@ -0,0 +1,346 @@
|
||||
// The template and inlines for the -*- C++ -*- internal _Array helper class.
|
||||
|
||||
// Copyright (C) 1997-1999 Cygnus Solutions
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
|
||||
|
||||
#ifndef __VALARRAY_ARRAY__
|
||||
#define __VALARRAY_ARRAY__
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
extern "C++" {
|
||||
|
||||
//
|
||||
// Helper functions on raw pointers
|
||||
//
|
||||
|
||||
// fill plain array __a[<__n>] with __t
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_fill (_Tp* __restrict__ __a, size_t __n, const _Tp& __t)
|
||||
{ while (__n--) *__a++ = __t; }
|
||||
|
||||
// fill strided array __a[<__n-1 : __s>] with __t
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_fill (_Tp* __restrict__ __a, size_t __n,
|
||||
size_t __s, const _Tp& __t)
|
||||
{ for (size_t __i=0; __i<__n; ++__i, __a+=__s) *__a = __t; }
|
||||
|
||||
// fill indirect array __a[__i[<__n>]] with __i
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_fill(_Tp* __restrict__ __a, const size_t* __restrict__ __i,
|
||||
size_t __n, const _Tp& __t)
|
||||
{ for (size_t __j=0; __j<__n; ++__j, ++__i) __a[*__i] = __t; }
|
||||
|
||||
// copy plain array __a[<__n>] in __b[<__n>]
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_copy (const _Tp* __restrict__ __a, size_t __n,
|
||||
_Tp* __restrict__ __b)
|
||||
{ memcpy (__b, __a, __n * sizeof(_Tp)); }
|
||||
|
||||
// copy strided array __a[<__n : __s>] in plain __b[<__n>]
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_copy (const _Tp* __restrict__ __a, size_t __n, size_t __s,
|
||||
_Tp* __restrict__ __b)
|
||||
{ for (size_t __i=0; __i<__n; ++__i, ++__b, __a += __s) *__b += *__a; }
|
||||
|
||||
// copy plain __a[<__n>] in strided __b[<__n : __s>]
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_copy (const _Tp* __restrict__ __a, _Tp* __restrict__ __b,
|
||||
size_t __n, size_t __s)
|
||||
{ for (size_t __i=0; __i<__n; ++__i, ++__a, __b+=__s) *__b = *__a; }
|
||||
|
||||
// copy indexed __a[__i[<__n>]] in plain __b[<__n>]
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_copy (const _Tp* __restrict__ __a,
|
||||
const size_t* __restrict__ __i,
|
||||
_Tp* __restrict__ __b, size_t __n)
|
||||
{ for (size_t __j=0; __j<__n; ++__j, ++__b, ++__i) *__b = __a[*__i]; }
|
||||
|
||||
// copy plain __a[<__n>] in indexed __b[__i[<__n>]]
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_copy (const _Tp* __restrict__ __a, size_t __n,
|
||||
_Tp* __restrict__ __b, const size_t* __restrict__ __i)
|
||||
{ for (size_t __j=0; __j<__n; ++__j, ++__a, ++__i) __b[*__i] = *__a; }
|
||||
|
||||
//
|
||||
// Helper class _Array, first layer of valarray abstraction.
|
||||
// All operations on valarray should be forwarded to this class
|
||||
// whenever possible. -- gdr
|
||||
//
|
||||
|
||||
template<typename _Tp> struct _Array {
|
||||
|
||||
explicit _Array (size_t);
|
||||
explicit _Array (_Tp* const __restrict__);
|
||||
explicit _Array (const valarray<_Tp>&);
|
||||
_Array (const _Tp* __restrict__, size_t);
|
||||
|
||||
void free_data() const;
|
||||
_Tp* begin () const;
|
||||
|
||||
_Tp* const __restrict__ _M_data;
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_fill (_Array<_Tp> __a, size_t __n, const _Tp& __t)
|
||||
{ __valarray_fill (__a._M_data, __n, __t); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_fill (_Array<_Tp> __a, size_t __n, size_t __s, const _Tp& __t)
|
||||
{ __valarray_fill (__a._M_data, __n, __s, __t); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_fill (_Array<_Tp> __a, _Array<size_t> __i,
|
||||
size_t __n, const _Tp& __t)
|
||||
{ __valarray_fill (__a._M_data, __i._M_data, __n, __t); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_copy (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b)
|
||||
{ __valarray_copy (__a._M_data, __n, __b._M_data); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_copy (_Array<_Tp> __a, size_t __n, size_t __s, _Array<_Tp> __b)
|
||||
{ __valarray_copy(__a._M_data, __n, __s, __b._M_data); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_copy (_Array<_Tp> __a, _Array<_Tp> __b, size_t __n, size_t __s)
|
||||
{ __valarray_copy (__a._M_data, __b._M_data, __n, __s); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_copy (_Array<_Tp> __a, _Array<size_t> __i,
|
||||
_Array<_Tp> __b, size_t __n)
|
||||
{ __valarray_copy (__a._M_data, __i._M_data, __b._M_data, __n); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
__valarray_copy (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b,
|
||||
_Array<size_t> __i)
|
||||
{ __valarray_copy (__a._M_data, __n, __b._M_data, __i._M_data); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline
|
||||
_Array<_Tp>::_Array (size_t __n) : _M_data (new _Tp[__n]) {}
|
||||
|
||||
template<typename _Tp>
|
||||
inline
|
||||
_Array<_Tp>::_Array (_Tp* const __restrict__ __p) : _M_data (__p) {}
|
||||
|
||||
template<typename _Tp>
|
||||
inline _Array<_Tp>::_Array (const valarray<_Tp>& __v)
|
||||
: _M_data (__v._M_data) {}
|
||||
|
||||
template<typename _Tp>
|
||||
inline
|
||||
_Array<_Tp>::_Array (const _Tp* __restrict__ __b, size_t __s)
|
||||
: _M_data (new _Tp[__s]) { __valarray_copy (__b, __s, _M_data); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
_Array<_Tp>::free_data() const { delete[] _M_data; }
|
||||
|
||||
template<typename _Tp>
|
||||
inline _Tp*
|
||||
_Array<_Tp>::begin () const
|
||||
{ return _M_data; }
|
||||
|
||||
#define _DEFINE_ARRAY_FUNCTION(_Op, _Name) \
|
||||
template<typename _Tp> \
|
||||
inline void \
|
||||
_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, const _Tp& __t) \
|
||||
{ \
|
||||
for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p) \
|
||||
*__p _Op##= __t; \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp> \
|
||||
inline void \
|
||||
_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) \
|
||||
{ \
|
||||
_Tp* __p (__a._M_data); \
|
||||
for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__p, ++__q) \
|
||||
*__p _Op##= *__q; \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp, class _Dom> \
|
||||
void \
|
||||
_Array_augmented_##_Name (_Array<_Tp> __a, \
|
||||
const _Expr<_Dom,_Tp>& __e, size_t __n) \
|
||||
{ \
|
||||
_Tp* __p (__a._M_data); \
|
||||
for (size_t __i=0; __i<__n; ++__i, ++__p) *__p _Op##= __e[__i]; \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp> \
|
||||
inline void \
|
||||
_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, size_t __s, \
|
||||
_Array<_Tp> __b) \
|
||||
{ \
|
||||
_Tp* __q (__b._M_data); \
|
||||
for (_Tp* __p=__a._M_data; __p<__a._M_data+__s*__n; __p+=__s, ++__q) \
|
||||
*__p _Op##= *__q; \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp> \
|
||||
inline void \
|
||||
_Array_augmented_##_Name (_Array<_Tp> __a, _Array<_Tp> __b, \
|
||||
size_t __n, size_t __s) \
|
||||
{ \
|
||||
_Tp* __q (__b._M_data); \
|
||||
for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, __q+=__s) \
|
||||
*__p _Op##= *__q; \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp, class _Dom> \
|
||||
void \
|
||||
_Array_augmented_##_Name (_Array<_Tp> __a, size_t __s, \
|
||||
const _Expr<_Dom,_Tp>& __e, size_t __n) \
|
||||
{ \
|
||||
_Tp* __p (__a._M_data); \
|
||||
for (size_t __i=0; __i<__n; ++__i, __p+=__s) *__p _Op##= __e[__i]; \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp> \
|
||||
inline void \
|
||||
_Array_augmented_##_Name (_Array<_Tp> __a, _Array<size_t> __i, \
|
||||
_Array<_Tp> __b, size_t __n) \
|
||||
{ \
|
||||
_Tp* __q (__b._M_data); \
|
||||
for (size_t* __j=__i._M_data; __j<__i._M_data+__n; ++__j, ++__q) \
|
||||
__a._M_data[*__j] _Op##= *__q; \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp> \
|
||||
inline void \
|
||||
_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, \
|
||||
_Array<_Tp> __b, _Array<size_t> __i) \
|
||||
{ \
|
||||
_Tp* __p (__a._M_data); \
|
||||
for (size_t* __j=__i._M_data; __j<__i._M_data+__n; ++__j, ++__p) \
|
||||
*__p _Op##= __b._M_data[*__j]; \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp, class _Dom> \
|
||||
void \
|
||||
_Array_augmented_##_Name (_Array<_Tp> __a, _Array<size_t> __i, \
|
||||
const _Expr<_Dom, _Tp>& __e, size_t __n) \
|
||||
{ \
|
||||
size_t* __j (__i._M_data); \
|
||||
for (size_t __k=0; __k<__n; ++__k, ++__j) \
|
||||
__a._M_data[*__j] _Op##= __e[__k]; \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp> \
|
||||
void \
|
||||
_Array_augmented_##_Name (_Array<_Tp> __a, _Array<bool> __m, \
|
||||
_Array<_Tp> __b, size_t __n) \
|
||||
{ \
|
||||
bool* ok (__m._M_data); \
|
||||
_Tp* __p (__a._M_data); \
|
||||
for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__q, ++ok, ++__p) { \
|
||||
while (! *ok) { \
|
||||
++ok; \
|
||||
++__p; \
|
||||
} \
|
||||
*__p _Op##= *__q; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp> \
|
||||
void \
|
||||
_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, \
|
||||
_Array<_Tp> __b, _Array<bool> __m) \
|
||||
{ \
|
||||
bool* ok (__m._M_data); \
|
||||
_Tp* __q (__b._M_data); \
|
||||
for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, ++ok, ++__q) { \
|
||||
while (! *ok) { \
|
||||
++ok; \
|
||||
++__q; \
|
||||
} \
|
||||
*__p _Op##= *__q; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
template<typename _Tp, class _Dom> \
|
||||
void \
|
||||
_Array_augmented_##_Name (_Array<_Tp> __a, _Array<bool> __m, \
|
||||
const _Expr<_Dom, _Tp>& __e, size_t __n) \
|
||||
{ \
|
||||
bool* ok(__m._M_data); \
|
||||
_Tp* __p (__a._M_data); \
|
||||
for (size_t __i=0; __i<__n; ++__i, ++ok, ++__p) { \
|
||||
while (! *ok) { \
|
||||
++ok; \
|
||||
++__p; \
|
||||
} \
|
||||
*__p _Op##= __e[__i]; \
|
||||
} \
|
||||
}
|
||||
|
||||
_DEFINE_ARRAY_FUNCTION(+, plus)
|
||||
_DEFINE_ARRAY_FUNCTION(-, minus)
|
||||
_DEFINE_ARRAY_FUNCTION(*, multiplies)
|
||||
_DEFINE_ARRAY_FUNCTION(/, divides)
|
||||
_DEFINE_ARRAY_FUNCTION(%, modulus)
|
||||
_DEFINE_ARRAY_FUNCTION(^, xor)
|
||||
_DEFINE_ARRAY_FUNCTION(|, or)
|
||||
_DEFINE_ARRAY_FUNCTION(&, and)
|
||||
_DEFINE_ARRAY_FUNCTION(<<, shift_left)
|
||||
_DEFINE_ARRAY_FUNCTION(>>, shift_right)
|
||||
|
||||
#undef _DEFINE_ARRAY_FUNCTION
|
||||
|
||||
} // extern "C++"
|
||||
|
||||
#ifdef _G_NO_VALARRAY_TEMPLATE_EXPORT
|
||||
# define export
|
||||
# include <std/valarray_array.tcc>
|
||||
#endif
|
||||
|
||||
#endif // __VALARRAY_ARRAY__
|
||||
|
||||
// Local Variables:
|
||||
// mode:c++
|
||||
// End:
|
130
contrib/libstdc++/std/valarray_array.tcc
Normal file
130
contrib/libstdc++/std/valarray_array.tcc
Normal file
@ -0,0 +1,130 @@
|
||||
// The template and inlines for the -*- C++ -*- internal _Array helper class.
|
||||
|
||||
// Copyright (C) 1997-1999 Cygnus Solutions
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
|
||||
|
||||
#ifndef __VALARRAY_ARRAY_TCC__
|
||||
#define __VALARRAY_ARRAY_TCC__
|
||||
|
||||
extern "C++" {
|
||||
|
||||
export template<typename _Tp>
|
||||
void
|
||||
__valarray_fill (_Array<_Tp> __a, size_t __n, _Array<bool> __m, const _Tp& __t)
|
||||
{
|
||||
_Tp* __p = __a._M_data;
|
||||
bool* __ok (__m._M_data);
|
||||
for (size_t __i=0; __i<__n; ++__i, ++__ok, ++__p) {
|
||||
while (! *__ok) {
|
||||
++__ok;
|
||||
++__p;
|
||||
}
|
||||
*__p = __t;
|
||||
}
|
||||
}
|
||||
|
||||
export template<typename _Tp>
|
||||
void
|
||||
__valarray_copy (_Array<_Tp> __a, _Array<bool> __m, _Array<_Tp> __b, size_t __n)
|
||||
{
|
||||
_Tp* __p (__a._M_data);
|
||||
bool* __ok (__m._M_data);
|
||||
for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__q, ++__ok, ++__p) {
|
||||
while (! *__ok) {
|
||||
++__ok;
|
||||
++__p;
|
||||
}
|
||||
*__q = *__p;
|
||||
}
|
||||
}
|
||||
|
||||
export template<typename _Tp>
|
||||
void
|
||||
__valarray_copy (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b, _Array<bool> __m)
|
||||
{
|
||||
_Tp* __q (__b._M_data);
|
||||
bool* __ok (__m._M_data);
|
||||
for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, ++__ok, ++__q) {
|
||||
while (! *__ok) {
|
||||
++__ok;
|
||||
++__q;
|
||||
}
|
||||
*__q = *__p;
|
||||
}
|
||||
}
|
||||
|
||||
export template<typename _Tp, class _Dom>
|
||||
void
|
||||
__valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n, _Array<_Tp> __a)
|
||||
{
|
||||
_Tp* __p (__a._M_data);
|
||||
for (size_t __i=0; __i<__n; ++__i, ++__p) *__p = __e[__i];
|
||||
}
|
||||
|
||||
export template<typename _Tp, class _Dom>
|
||||
void
|
||||
__valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n,
|
||||
_Array<_Tp> __a, size_t __s)
|
||||
{
|
||||
_Tp* __p (__a._M_data);
|
||||
for (size_t __i=0; __i<__n; ++__i, __p+=__s) *__p = __e[__i];
|
||||
}
|
||||
|
||||
export template<typename _Tp, class _Dom>
|
||||
void
|
||||
__valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n,
|
||||
_Array<_Tp> __a, _Array<size_t> __i)
|
||||
{
|
||||
size_t* __j (__i._M_data);
|
||||
for (size_t __k=0; __k<__n; ++__k, ++__j) __a._M_data[*__j] = __e[__k];
|
||||
}
|
||||
|
||||
export template<typename _Tp, class _Dom>
|
||||
void
|
||||
__valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n,
|
||||
_Array<_Tp> __a, _Array<bool> __m)
|
||||
{
|
||||
bool* __ok (__m._M_data);
|
||||
_Tp* __p (__a._M_data);
|
||||
for (size_t __i=0; __i<__n; ++__i, ++__ok, ++__p) {
|
||||
while (! *__ok) {
|
||||
++__ok;
|
||||
++__p;
|
||||
}
|
||||
*__p = __e[__i];
|
||||
}
|
||||
}
|
||||
|
||||
} // extern "C++"
|
||||
|
||||
#endif // __VALARRAY_ARRAY_TCC__
|
||||
|
||||
// Local Variables:
|
||||
// mode:c++
|
||||
// End:
|
1045
contrib/libstdc++/std/valarray_meta.h
Normal file
1045
contrib/libstdc++/std/valarray_meta.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -37,9 +37,7 @@
|
||||
|
||||
extern "C++" {
|
||||
|
||||
#ifdef __HONOR_STD
|
||||
namespace std {
|
||||
#endif
|
||||
|
||||
class logic_error : public exception {
|
||||
string _what;
|
||||
@ -92,9 +90,7 @@ public:
|
||||
underflow_error (const string& what_arg): runtime_error (what_arg) { }
|
||||
};
|
||||
|
||||
#ifdef __HONOR_STD
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
} // extern "C++"
|
||||
|
||||
|
@ -12,10 +12,10 @@
|
||||
void
|
||||
__out_of_range (const char *s)
|
||||
{
|
||||
throw out_of_range (s);
|
||||
throw std::out_of_range (s);
|
||||
}
|
||||
|
||||
void __length_error (const char *s)
|
||||
{
|
||||
throw length_error (s);
|
||||
throw std::length_error (s);
|
||||
}
|
||||
|
@ -1,6 +1,103 @@
|
||||
Sun Mar 14 02:38:07 PST 1999 Jeff Law (law@cygnus.com)
|
||||
Mon Aug 16 01:29:24 PDT 1999 Jeff Law (law@cygnus.com)
|
||||
|
||||
* egcs-1.1.2 Released.
|
||||
* gcc-2.95.1 Released.
|
||||
|
||||
Sun Aug 8 21:06:16 1999 Alexandre Oliva <oliva@dcc.unicamp.br>
|
||||
|
||||
* pthread_alloc: Solaris' ctype.h defines _U to 01; use _Up as
|
||||
template parameter instead.
|
||||
|
||||
Wed Jul 28 21:39:31 PDT 1999 Jeff Law (law@cygnus.com)
|
||||
|
||||
* gcc-2.95 Released.
|
||||
|
||||
Sun Jul 25 23:40:51 PDT 1999 Jeff Law (law@cygnus.com)
|
||||
|
||||
* gcc-2.95 Released.
|
||||
|
||||
1999-07-11 Martin v. Löwis (loewis@informatik.hu-berlin.de)
|
||||
|
||||
* stl_function.h (bind1st, bind2nd): Rename __opr to __oper,
|
||||
as __opr is used internally by egcs.
|
||||
* stl_numeric.h (__power, power): Likewise.
|
||||
|
||||
1999-06-18 Martin von Löwis <loewis@informatik.hu-berlin.de>
|
||||
|
||||
* stl_queue.h: Rename _M_c to c, and _M_comp to comp.
|
||||
|
||||
1999-06-17 Alexandre Oliva <oliva@dcc.unicamp.br>
|
||||
|
||||
* stl_algo.h (transform): Rename __opr to __oper, as __opr is used
|
||||
internally by egcs.
|
||||
Reported by Harri Porten <porten@tu-harburg.de>
|
||||
|
||||
1999-05-17 Mark Kettenis <kettenis@gnu.org>
|
||||
|
||||
* stl_config.h: Only define __STL_PTHREADS with GLIBC >= 2 for
|
||||
Linux.
|
||||
|
||||
Mon May 17 03:33:47 1999 Mumit Khan <khan@xraylith.wisc.edu>
|
||||
|
||||
* stl_config.h (__CYGWIN__): Cygwin newlib RTL lacks drand48.
|
||||
|
||||
1999-05-07 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* stl_alloc.h: Make it possible to compile with __USE_MALLOC.
|
||||
|
||||
Tue Apr 13 00:32:57 1999 Mumit Khan <khan@xraylith.wisc.edu>
|
||||
|
||||
* stl_config.h (__MINGW32__): Mingw32 RTL lacks drand48.
|
||||
|
||||
Sun Apr 11 23:48:30 1999 Jeffrey A Law (law@cygnus.com)
|
||||
|
||||
* bitset: Re-install Alexandre's lost patch from 1998-11-27.
|
||||
|
||||
1999-01-20 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* stl_construct.h (__destroy_aux): Use != instead of < for
|
||||
ForwardIterator comparison.
|
||||
Patch by jmaurer@menuett.rhein-main.de (Jens Maurer).
|
||||
|
||||
1999-01-20 Mark Mitchell <mark@markmitchell.com>
|
||||
|
||||
* stl_config.h (__STL_USE_NAMESPACES): Define.
|
||||
|
||||
1998-11-27 Alexandre Oliva <oliva@dcc.unicamp.br>
|
||||
|
||||
* bitset: Explicitly convert basic_string<...>::npos to size_t in
|
||||
default argument to constructor, to avoid parse error at `>'.
|
||||
(__STL_EXPLICIT_FUNCTION_TMPL_ARGS): Replace #if with #ifdef.
|
||||
|
||||
1998-11-01 Mark Mitchell <mark@markmitchell.com>
|
||||
|
||||
* stl_alloc.h (default_alloc_template::_S_free_list): Don't
|
||||
qualify _NFREELISTS.
|
||||
|
||||
1998-10-11 Mark Mitchell <mark@markmitchell.com>
|
||||
|
||||
* stl_config.h (__SGI_STL_USE_AUTO_PTR_CONVERSIONS): Define.
|
||||
* memory (auto_ptr::operator auto_ptr_ref<_Tp1>): Fix typo.
|
||||
(auto_ptr::operator auto_ptr<_Tp1>): Add missing
|
||||
semicolon.
|
||||
|
||||
1998-09-03 Jason Merrill <jason@yorick.cygnus.com>
|
||||
|
||||
* stl_config.h: Define __STL_HAS_WCHAR_T,
|
||||
__STL_MEMBER_TEMPLATE_CLASSES, __STL_HAS_NAMESPACES,
|
||||
__STL_NO_NAMESPACES and __STL_LONG_LONG.
|
||||
|
||||
1998-09-02 Jason Merrill <jason@yorick.cygnus.com>
|
||||
|
||||
* algorithm alloc.h defalloc.h hash_map.h hash_set.h iterator
|
||||
memory pthread_alloc pthread_alloc.h rope ropeimpl.h stl_algo.h
|
||||
stl_algobase.h stl_alloc.h stl_bvector.h stl_config.h
|
||||
stl_construct.h stl_deque.h stl_function.h stl_hash_fun.h
|
||||
stl_hash_map.h stl_hash_set.h stl_hashtable.h stl_heap.h
|
||||
stl_iterator.h stl_list.h stl_map.h stl_multimap.h stl_multiset.h
|
||||
stl_numeric.h stl_pair.h stl_queue.h stl_raw_storage_iter.h
|
||||
stl_relops.h stl_rope.h stl_set.h stl_slist.h stl_stack.h
|
||||
stl_tempbuf.h stl_tree.h stl_uninitialized.h stl_vector.h
|
||||
tempbuf.h type_traits.h: Update to SGI STL 3.11.
|
||||
|
||||
Fri Jul 10 15:20:09 1998 Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de>
|
||||
|
||||
@ -93,7 +190,7 @@ Fri Jul 04 02:17:15 1997 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* tree.h (rb_tree): Reverse order of member initializations
|
||||
to prevent warnings.
|
||||
|
||||
|
||||
Sun Jun 15 18:17:21 1997 Jason Merrill <jason@yorick.cygnus.com>
|
||||
|
||||
* *.h: Update to 6/13 SGI release.
|
||||
@ -131,7 +228,7 @@ Mon Sep 30 17:56:43 1996 Jason Merrill <jason@yorick.cygnus.com>
|
||||
|
||||
Fri Sep 27 19:03:06 1996 Jason Merrill <jason@yorick.cygnus.com>
|
||||
|
||||
* alloc.h (__default_alloc_template): lock is a friend.
|
||||
* alloc.h (__default_alloc_template): lock is a friend.
|
||||
|
||||
Thu Sep 19 20:10:37 1996 Jason Merrill <jason@yorick.cygnus.com>
|
||||
|
||||
@ -269,5 +366,3 @@ Fri Dec 30 16:29:39 1994 Mike Stump <mrs@cygnus.com>
|
||||
Tue Nov 29 15:30:30 1994 Per Bothner <bothner@kalessin.cygnus.com>
|
||||
|
||||
* Initial check-in, based on HP's October 21, 1994.
|
||||
|
||||
|
||||
|
@ -1,16 +1,13 @@
|
||||
This directory contains an SGI release of the C++ Standard Template
|
||||
Library, slightly modified to work with g++ (version 2.8.0 or newer).
|
||||
Library, slightly modified to work with g++.
|
||||
|
||||
Note that this is based on a pre-Draft Standard for C++.
|
||||
Things are likely to change. For example, the header file names
|
||||
are very likely to change. The Allocator interface will change. Etc, etc.
|
||||
CYGNUS MAKES NO COMMITTMENT (yet) TO SUPPORT BACKWARD COMPATIBILITY FOR STL.
|
||||
|
||||
For examples if things that should work, look in the ../tests directory.
|
||||
For examples of things that should work, look in the ../tests directory.
|
||||
|
||||
DOCUMENTATION:
|
||||
See http://www.sgi.com/Technology/STL/ or http://www.dinkumware.com/
|
||||
on the World-Wide Web.
|
||||
|
||||
--Jason Merrill
|
||||
Cygnus Support jason@cygnus.com
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include <stl_algobase.h>
|
||||
#include <stl_construct.h>
|
||||
#include <stl_uninitialized.h>
|
||||
#include <stl_tempbuf.h>
|
||||
#include <stl_algo.h>
|
||||
|
||||
|
@ -33,7 +33,9 @@ using __STD::single_client_alloc;
|
||||
#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG
|
||||
using __STD::__malloc_alloc_oom_handler;
|
||||
#endif /* __STL_STATIC_TEMPLATE_MEMBER_BUG */
|
||||
|
||||
#ifdef __STL_USE_STD_ALLOCATORS
|
||||
using __STD::allocator;
|
||||
#endif /* __STL_USE_STD_ALLOCATORS */
|
||||
|
||||
#endif /* __STL_USE_NAMESPACES */
|
||||
|
||||
|
1063
contrib/libstdc++/stl/bitset
Normal file
1063
contrib/libstdc++/stl/bitset
Normal file
File diff suppressed because it is too large
Load Diff
@ -15,12 +15,13 @@
|
||||
|
||||
// Inclusion of this file is DEPRECATED. This is the original HP
|
||||
// default allocator. It is provided only for backward compatibility.
|
||||
//
|
||||
// This file WILL BE REMOVED in a future release.
|
||||
//
|
||||
// DO NOT USE THIS FILE unless you have an old container implementation
|
||||
// that requires an allocator with the HP-style interface. SGI STL
|
||||
// uses a different allocator interface. SGI-style allocators are not
|
||||
// parametrized with respect to the object type; they traffic in void *
|
||||
// pointers. This file is not included by any other SGI STL header.
|
||||
// that requires an allocator with the HP-style interface.
|
||||
//
|
||||
// Standard-conforming allocators have a very different interface. The
|
||||
// standard default allocator is declared in the header <memory>.
|
||||
|
||||
#ifndef DEFALLOC_H
|
||||
#define DEFALLOC_H
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <stl_hashtable.h>
|
||||
#endif
|
||||
|
||||
#include <algobase.h>
|
||||
#include <stl_hash_map.h>
|
||||
|
||||
#ifdef __STL_USE_NAMESPACES
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <stl_hashtable.h>
|
||||
#endif
|
||||
|
||||
#include <algobase.h>
|
||||
#include <stl_hash_set.h>
|
||||
|
||||
#ifdef __STL_USE_NAMESPACES
|
||||
|
@ -29,8 +29,12 @@
|
||||
|
||||
#include <stl_config.h>
|
||||
#include <stl_relops.h>
|
||||
#include <stddef.h>
|
||||
#include <stddef.h> /* XXX should use <cstddef> */
|
||||
#if 0 /* XXX define a flag for this */
|
||||
#include <iostream>
|
||||
#else
|
||||
#include <iostream.h>
|
||||
#endif
|
||||
#include <stl_iterator.h>
|
||||
|
||||
#endif /* __SGI_STL_ITERATOR */
|
||||
|
@ -22,64 +22,83 @@
|
||||
#include <stl_uninitialized.h>
|
||||
#include <stl_raw_storage_iter.h>
|
||||
|
||||
// Note: auto_ptr is commented out in this release because the details
|
||||
// of the interface are still being discussed by the C++ standardization
|
||||
// committee. It will be included once the iterface is finalized.
|
||||
|
||||
#if 0
|
||||
#if defined(_MUTABLE_IS_KEYWORD) && defined(_EXPLICIT_IS_KEYWORD) && \
|
||||
defined(__STL_MEMBER_TEMPLATES)
|
||||
#if defined(__STL_MEMBER_TEMPLATES)
|
||||
|
||||
__STL_BEGIN_NAMESPACE
|
||||
|
||||
template <class X> class auto_ptr {
|
||||
template <class _Tp> class auto_ptr {
|
||||
private:
|
||||
X* ptr;
|
||||
mutable bool owns;
|
||||
_Tp* _M_ptr;
|
||||
|
||||
public:
|
||||
typedef X element_type;
|
||||
explicit auto_ptr(X* p = 0) __STL_NOTHROW : ptr(p), owns(p) {}
|
||||
auto_ptr(const auto_ptr& a) __STL_NOTHROW : ptr(a.ptr), owns(a.owns) {
|
||||
a.owns = 0;
|
||||
typedef _Tp element_type;
|
||||
explicit auto_ptr(_Tp* __p = 0) __STL_NOTHROW : _M_ptr(__p) {}
|
||||
auto_ptr(auto_ptr& __a) __STL_NOTHROW : _M_ptr(__a.release()) {}
|
||||
template <class _Tp1> auto_ptr(auto_ptr<_Tp1>& __a) __STL_NOTHROW
|
||||
: _M_ptr(__a.release()) {}
|
||||
auto_ptr& operator=(auto_ptr& __a) __STL_NOTHROW {
|
||||
if (&__a != this) {
|
||||
delete _M_ptr;
|
||||
_M_ptr = __a.release();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
template <class T> auto_ptr(const auto_ptr<T>& a) __STL_NOTHROW
|
||||
: ptr(a.ptr), owns(a.owns) {
|
||||
a.owns = 0;
|
||||
template <class _Tp1>
|
||||
auto_ptr& operator=(auto_ptr<_Tp1>& __a) __STL_NOTHROW {
|
||||
if (__a.get() != this->get()) {
|
||||
delete _M_ptr;
|
||||
_M_ptr = __a.release();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
~auto_ptr() __STL_NOTHROW { delete _M_ptr; }
|
||||
|
||||
_Tp& operator*() const __STL_NOTHROW {
|
||||
return *_M_ptr;
|
||||
}
|
||||
_Tp* operator->() const __STL_NOTHROW {
|
||||
return _M_ptr;
|
||||
}
|
||||
_Tp* get() const __STL_NOTHROW {
|
||||
return _M_ptr;
|
||||
}
|
||||
_Tp* release() __STL_NOTHROW {
|
||||
_Tp* __tmp = _M_ptr;
|
||||
_M_ptr = 0;
|
||||
return __tmp;
|
||||
}
|
||||
void reset(_Tp* __p = 0) __STL_NOTHROW {
|
||||
delete _M_ptr;
|
||||
_M_ptr = __p;
|
||||
}
|
||||
|
||||
auto_ptr& operator=(const auto_ptr& a) __STL_NOTHROW {
|
||||
if (&a != this) {
|
||||
if (owns)
|
||||
delete ptr;
|
||||
owns = a.owns;
|
||||
ptr = a.ptr;
|
||||
a.owns = 0;
|
||||
}
|
||||
}
|
||||
template <class T> auto_ptr& operator=(const auto_ptr<T>& a) __STL_NOTHROW {
|
||||
if (&a != this) {
|
||||
if (owns)
|
||||
delete ptr;
|
||||
owns = a.owns;
|
||||
ptr = a.ptr;
|
||||
a.owns = 0;
|
||||
}
|
||||
}
|
||||
~auto_ptr() {
|
||||
if (owns)
|
||||
delete ptr;
|
||||
}
|
||||
// According to the C++ standard, these conversions are required. Most
|
||||
// present-day compilers, however, do not enforce that requirement---and,
|
||||
// in fact, most present-day compilers do not support the language
|
||||
// features that these conversions rely on.
|
||||
|
||||
#ifdef __SGI_STL_USE_AUTO_PTR_CONVERSIONS
|
||||
|
||||
X& operator*() const __STL_NOTHROW { return *ptr; }
|
||||
X* operator->() const __STL_NOTHROW { return ptr; }
|
||||
X* get() const __STL_NOTHROW { return ptr; }
|
||||
X* release const __STL_NOTHROW { owns = false; return ptr }
|
||||
private:
|
||||
template<class _Tp1> struct auto_ptr_ref {
|
||||
_Tp1* _M_ptr;
|
||||
auto_ptr_ref(_Tp1* __p) : _M_ptr(__p) {}
|
||||
};
|
||||
|
||||
public:
|
||||
auto_ptr(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW
|
||||
: _M_ptr(__ref._M_ptr) {}
|
||||
template <class _Tp1> operator auto_ptr_ref<_Tp1>() __STL_NOTHROW
|
||||
{ return auto_ptr_ref<_Tp>(this->release()); }
|
||||
template <class _Tp1> operator auto_ptr<_Tp1>() __STL_NOTHROW
|
||||
{ return auto_ptr<_Tp1>(this->release()); }
|
||||
|
||||
#endif /* __SGI_STL_USE_AUTO_PTR_CONVERSIONS */
|
||||
};
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
#endif /* mutable && explicit && member templates */
|
||||
#endif /* 0 */
|
||||
|
||||
#endif /* member templates */
|
||||
|
||||
#endif /* __SGI_STL_MEMORY */
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
// This should be reasonably fast even in the presence of threads.
|
||||
// The down side is that storage may not be well-utilized.
|
||||
// It is not an error to allocate memory in thread A and deallocate
|
||||
// it n thread B. But this effectively transfers ownership of the memory,
|
||||
// it in thread B. But this effectively transfers ownership of the memory,
|
||||
// so that it can only be reallocated by thread B. Thus this can effectively
|
||||
// result in a storage leak if it's done on a regular basis.
|
||||
// It can also result in frequent sharing of
|
||||
@ -35,308 +35,440 @@
|
||||
|
||||
__STL_BEGIN_NAMESPACE
|
||||
|
||||
// Note that this class has nonstatic members. We instantiate it once
|
||||
// per thread.
|
||||
template <bool dummy>
|
||||
class __pthread_alloc_template {
|
||||
#define __STL_DATA_ALIGNMENT 8
|
||||
|
||||
private:
|
||||
enum {ALIGN = 8};
|
||||
enum {MAX_BYTES = 128}; // power of 2
|
||||
enum {NFREELISTS = MAX_BYTES/ALIGN};
|
||||
union _Pthread_alloc_obj {
|
||||
union _Pthread_alloc_obj * __free_list_link;
|
||||
char __client_data[__STL_DATA_ALIGNMENT]; /* The client sees this. */
|
||||
};
|
||||
|
||||
union obj {
|
||||
union obj * free_list_link;
|
||||
char client_data[ALIGN]; /* The client sees this. */
|
||||
};
|
||||
// Pthread allocators don't appear to the client to have meaningful
|
||||
// instances. We do in fact need to associate some state with each
|
||||
// thread. That state is represented by
|
||||
// _Pthread_alloc_per_thread_state<_Max_size>.
|
||||
|
||||
// Per instance state
|
||||
obj* volatile free_list[NFREELISTS];
|
||||
__pthread_alloc_template<dummy>* next; // Free list link
|
||||
|
||||
static size_t ROUND_UP(size_t bytes) {
|
||||
return (((bytes) + ALIGN-1) & ~(ALIGN - 1));
|
||||
}
|
||||
static size_t FREELIST_INDEX(size_t bytes) {
|
||||
return (((bytes) + ALIGN-1)/ALIGN - 1);
|
||||
template<size_t _Max_size>
|
||||
struct _Pthread_alloc_per_thread_state {
|
||||
typedef _Pthread_alloc_obj __obj;
|
||||
enum { _S_NFREELISTS = _Max_size/__STL_DATA_ALIGNMENT };
|
||||
_Pthread_alloc_obj* volatile __free_list[_S_NFREELISTS];
|
||||
_Pthread_alloc_per_thread_state<_Max_size> * __next;
|
||||
// Free list link for list of available per thread structures.
|
||||
// When one of these becomes available for reuse due to thread
|
||||
// termination, any objects in its free list remain associated
|
||||
// with it. The whole structure may then be used by a newly
|
||||
// created thread.
|
||||
_Pthread_alloc_per_thread_state() : __next(0)
|
||||
{
|
||||
memset((void *)__free_list, 0, _S_NFREELISTS * sizeof(__obj *));
|
||||
}
|
||||
// Returns an object of size __n, and possibly adds to size n free list.
|
||||
void *_M_refill(size_t __n);
|
||||
};
|
||||
|
||||
// Pthread-specific allocator.
|
||||
// The argument specifies the largest object size allocated from per-thread
|
||||
// free lists. Larger objects are allocated using malloc_alloc.
|
||||
// Max_size must be a power of 2.
|
||||
template <size_t _Max_size = 128>
|
||||
class _Pthread_alloc_template {
|
||||
|
||||
public: // but only for internal use:
|
||||
|
||||
typedef _Pthread_alloc_obj __obj;
|
||||
|
||||
// Returns an object of size n, and optionally adds to size n free list.
|
||||
void *refill(size_t n);
|
||||
// Allocates a chunk for nobjs of size "size". nobjs may be reduced
|
||||
// if it is inconvenient to allocate the requested number.
|
||||
static char *chunk_alloc(size_t size, int &nobjs);
|
||||
static char *_S_chunk_alloc(size_t __size, int &__nobjs);
|
||||
|
||||
enum {_S_ALIGN = __STL_DATA_ALIGNMENT};
|
||||
|
||||
static size_t _S_round_up(size_t __bytes) {
|
||||
return (((__bytes) + _S_ALIGN-1) & ~(_S_ALIGN - 1));
|
||||
}
|
||||
static size_t _S_freelist_index(size_t __bytes) {
|
||||
return (((__bytes) + _S_ALIGN-1)/_S_ALIGN - 1);
|
||||
}
|
||||
|
||||
private:
|
||||
// Chunk allocation state. And other shared state.
|
||||
// Protected by chunk_allocator_lock.
|
||||
static pthread_mutex_t chunk_allocator_lock;
|
||||
static char *start_free;
|
||||
static char *end_free;
|
||||
static size_t heap_size;
|
||||
static __pthread_alloc_template<dummy>* free_allocators;
|
||||
static pthread_key_t key;
|
||||
static bool key_initialized;
|
||||
// Pthread key under which allocator is stored.
|
||||
// Allocator instances that are currently unclaimed by any thread.
|
||||
static void destructor(void *instance);
|
||||
// Function to be called on thread exit to reclaim allocator
|
||||
// instance.
|
||||
static __pthread_alloc_template<dummy> *new_allocator();
|
||||
// Return a recycled or new allocator instance.
|
||||
static __pthread_alloc_template<dummy> *get_allocator_instance();
|
||||
// ensure that the current thread has an associated
|
||||
// allocator instance.
|
||||
class lock {
|
||||
// Protected by _S_chunk_allocator_lock.
|
||||
static pthread_mutex_t _S_chunk_allocator_lock;
|
||||
static char *_S_start_free;
|
||||
static char *_S_end_free;
|
||||
static size_t _S_heap_size;
|
||||
static _Pthread_alloc_per_thread_state<_Max_size>* _S_free_per_thread_states;
|
||||
static pthread_key_t _S_key;
|
||||
static bool _S_key_initialized;
|
||||
// Pthread key under which per thread state is stored.
|
||||
// Allocator instances that are currently unclaimed by any thread.
|
||||
static void _S_destructor(void *instance);
|
||||
// Function to be called on thread exit to reclaim per thread
|
||||
// state.
|
||||
static _Pthread_alloc_per_thread_state<_Max_size> *_S_new_per_thread_state();
|
||||
// Return a recycled or new per thread state.
|
||||
static _Pthread_alloc_per_thread_state<_Max_size> *_S_get_per_thread_state();
|
||||
// ensure that the current thread has an associated
|
||||
// per thread state.
|
||||
friend class _M_lock;
|
||||
class _M_lock {
|
||||
public:
|
||||
lock () { pthread_mutex_lock(&chunk_allocator_lock); }
|
||||
~lock () { pthread_mutex_unlock(&chunk_allocator_lock); }
|
||||
_M_lock () { pthread_mutex_lock(&_S_chunk_allocator_lock); }
|
||||
~_M_lock () { pthread_mutex_unlock(&_S_chunk_allocator_lock); }
|
||||
};
|
||||
friend class lock;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
__pthread_alloc_template() : next(0)
|
||||
/* n must be > 0 */
|
||||
static void * allocate(size_t __n)
|
||||
{
|
||||
memset((void *)free_list, 0, NFREELISTS * sizeof(obj *));
|
||||
}
|
||||
__obj * volatile * __my_free_list;
|
||||
__obj * __RESTRICT __result;
|
||||
_Pthread_alloc_per_thread_state<_Max_size>* __a;
|
||||
|
||||
/* n must be > 0 */
|
||||
static void * allocate(size_t n)
|
||||
{
|
||||
obj * volatile * my_free_list;
|
||||
obj * __RESTRICT result;
|
||||
__pthread_alloc_template<dummy>* a;
|
||||
|
||||
if (n > MAX_BYTES) {
|
||||
return(malloc(n));
|
||||
if (__n > _Max_size) {
|
||||
return(malloc_alloc::allocate(__n));
|
||||
}
|
||||
if (!key_initialized ||
|
||||
!(a = (__pthread_alloc_template<dummy>*)
|
||||
pthread_getspecific(key))) {
|
||||
a = get_allocator_instance();
|
||||
if (!_S_key_initialized ||
|
||||
!(__a = (_Pthread_alloc_per_thread_state<_Max_size>*)
|
||||
pthread_getspecific(_S_key))) {
|
||||
__a = _S_get_per_thread_state();
|
||||
}
|
||||
my_free_list = a -> free_list + FREELIST_INDEX(n);
|
||||
result = *my_free_list;
|
||||
if (result == 0) {
|
||||
void *r = a -> refill(ROUND_UP(n));
|
||||
return r;
|
||||
__my_free_list = __a -> __free_list + _S_freelist_index(__n);
|
||||
__result = *__my_free_list;
|
||||
if (__result == 0) {
|
||||
void *__r = __a -> _M_refill(_S_round_up(__n));
|
||||
return __r;
|
||||
}
|
||||
*my_free_list = result -> free_list_link;
|
||||
return (result);
|
||||
*__my_free_list = __result -> __free_list_link;
|
||||
return (__result);
|
||||
};
|
||||
|
||||
/* p may not be 0 */
|
||||
static void deallocate(void *p, size_t n)
|
||||
static void deallocate(void *__p, size_t __n)
|
||||
{
|
||||
obj *q = (obj *)p;
|
||||
obj * volatile * my_free_list;
|
||||
__pthread_alloc_template<dummy>* a;
|
||||
__obj *__q = (__obj *)__p;
|
||||
__obj * volatile * __my_free_list;
|
||||
_Pthread_alloc_per_thread_state<_Max_size>* __a;
|
||||
|
||||
if (n > MAX_BYTES) {
|
||||
free(p);
|
||||
return;
|
||||
if (__n > _Max_size) {
|
||||
malloc_alloc::deallocate(__p, __n);
|
||||
return;
|
||||
}
|
||||
if (!key_initialized ||
|
||||
!(a = (__pthread_alloc_template<dummy>*)
|
||||
pthread_getspecific(key))) {
|
||||
a = get_allocator_instance();
|
||||
if (!_S_key_initialized ||
|
||||
!(__a = (_Pthread_alloc_per_thread_state<_Max_size> *)
|
||||
pthread_getspecific(_S_key))) {
|
||||
__a = _S_get_per_thread_state();
|
||||
}
|
||||
my_free_list = a->free_list + FREELIST_INDEX(n);
|
||||
q -> free_list_link = *my_free_list;
|
||||
*my_free_list = q;
|
||||
__my_free_list = __a->__free_list + _S_freelist_index(__n);
|
||||
__q -> __free_list_link = *__my_free_list;
|
||||
*__my_free_list = __q;
|
||||
}
|
||||
|
||||
static void * reallocate(void *p, size_t old_sz, size_t new_sz);
|
||||
static void * reallocate(void *__p, size_t __old_sz, size_t __new_sz);
|
||||
|
||||
} ;
|
||||
|
||||
typedef __pthread_alloc_template<false> pthread_alloc;
|
||||
typedef _Pthread_alloc_template<> pthread_alloc;
|
||||
|
||||
|
||||
template <bool dummy>
|
||||
void __pthread_alloc_template<dummy>::destructor(void * instance)
|
||||
template <size_t _Max_size>
|
||||
void _Pthread_alloc_template<_Max_size>::_S_destructor(void * __instance)
|
||||
{
|
||||
__pthread_alloc_template<dummy>* a =
|
||||
(__pthread_alloc_template<dummy>*)instance;
|
||||
a -> next = free_allocators;
|
||||
free_allocators = a;
|
||||
_M_lock __lock_instance; // Need to acquire lock here.
|
||||
_Pthread_alloc_per_thread_state<_Max_size>* __s =
|
||||
(_Pthread_alloc_per_thread_state<_Max_size> *)__instance;
|
||||
__s -> __next = _S_free_per_thread_states;
|
||||
_S_free_per_thread_states = __s;
|
||||
}
|
||||
|
||||
template <bool dummy>
|
||||
__pthread_alloc_template<dummy>*
|
||||
__pthread_alloc_template<dummy>::new_allocator()
|
||||
{
|
||||
if (0 != free_allocators) {
|
||||
__pthread_alloc_template<dummy>* result = free_allocators;
|
||||
free_allocators = free_allocators -> next;
|
||||
return result;
|
||||
template <size_t _Max_size>
|
||||
_Pthread_alloc_per_thread_state<_Max_size> *
|
||||
_Pthread_alloc_template<_Max_size>::_S_new_per_thread_state()
|
||||
{
|
||||
/* lock already held here. */
|
||||
if (0 != _S_free_per_thread_states) {
|
||||
_Pthread_alloc_per_thread_state<_Max_size> *__result =
|
||||
_S_free_per_thread_states;
|
||||
_S_free_per_thread_states = _S_free_per_thread_states -> __next;
|
||||
return __result;
|
||||
} else {
|
||||
return new __pthread_alloc_template<dummy>;
|
||||
return new _Pthread_alloc_per_thread_state<_Max_size>;
|
||||
}
|
||||
}
|
||||
|
||||
template <bool dummy>
|
||||
__pthread_alloc_template<dummy>*
|
||||
__pthread_alloc_template<dummy>::get_allocator_instance()
|
||||
template <size_t _Max_size>
|
||||
_Pthread_alloc_per_thread_state<_Max_size> *
|
||||
_Pthread_alloc_template<_Max_size>::_S_get_per_thread_state()
|
||||
{
|
||||
__pthread_alloc_template<dummy>* result;
|
||||
if (!key_initialized) {
|
||||
/*REFERENCED*/
|
||||
lock lock_instance;
|
||||
if (!key_initialized) {
|
||||
if (pthread_key_create(&key, destructor)) {
|
||||
abort(); // failed
|
||||
}
|
||||
key_initialized = true;
|
||||
}
|
||||
/*REFERENCED*/
|
||||
_M_lock __lock_instance; // Need to acquire lock here.
|
||||
_Pthread_alloc_per_thread_state<_Max_size> * __result;
|
||||
if (!_S_key_initialized) {
|
||||
if (pthread_key_create(&_S_key, _S_destructor)) {
|
||||
abort(); // failed
|
||||
}
|
||||
_S_key_initialized = true;
|
||||
}
|
||||
result = new_allocator();
|
||||
if (pthread_setspecific(key, result)) abort();
|
||||
return result;
|
||||
__result = _S_new_per_thread_state();
|
||||
if (pthread_setspecific(_S_key, __result)) abort();
|
||||
return __result;
|
||||
}
|
||||
|
||||
/* We allocate memory in large chunks in order to avoid fragmenting */
|
||||
/* the malloc heap too much. */
|
||||
/* We assume that size is properly aligned. */
|
||||
template <bool dummy>
|
||||
char *__pthread_alloc_template<dummy>
|
||||
::chunk_alloc(size_t size, int &nobjs)
|
||||
/* We allocate memory in large chunks in order to avoid fragmenting */
|
||||
/* the malloc heap too much. */
|
||||
/* We assume that size is properly aligned. */
|
||||
template <size_t _Max_size>
|
||||
char *_Pthread_alloc_template<_Max_size>
|
||||
::_S_chunk_alloc(size_t __size, int &__nobjs)
|
||||
{
|
||||
{
|
||||
char * result;
|
||||
size_t total_bytes;
|
||||
size_t bytes_left;
|
||||
char * __result;
|
||||
size_t __total_bytes;
|
||||
size_t __bytes_left;
|
||||
/*REFERENCED*/
|
||||
lock lock_instance; // Acquire lock for this routine
|
||||
_M_lock __lock_instance; // Acquire lock for this routine
|
||||
|
||||
total_bytes = size * nobjs;
|
||||
bytes_left = end_free - start_free;
|
||||
if (bytes_left >= total_bytes) {
|
||||
result = start_free;
|
||||
start_free += total_bytes;
|
||||
return(result);
|
||||
} else if (bytes_left >= size) {
|
||||
nobjs = bytes_left/size;
|
||||
total_bytes = size * nobjs;
|
||||
result = start_free;
|
||||
start_free += total_bytes;
|
||||
return(result);
|
||||
__total_bytes = __size * __nobjs;
|
||||
__bytes_left = _S_end_free - _S_start_free;
|
||||
if (__bytes_left >= __total_bytes) {
|
||||
__result = _S_start_free;
|
||||
_S_start_free += __total_bytes;
|
||||
return(__result);
|
||||
} else if (__bytes_left >= __size) {
|
||||
__nobjs = __bytes_left/__size;
|
||||
__total_bytes = __size * __nobjs;
|
||||
__result = _S_start_free;
|
||||
_S_start_free += __total_bytes;
|
||||
return(__result);
|
||||
} else {
|
||||
size_t bytes_to_get = 2 * total_bytes + ROUND_UP(heap_size >> 4);
|
||||
// Try to make use of the left-over piece.
|
||||
if (bytes_left > 0) {
|
||||
__pthread_alloc_template<dummy>* a =
|
||||
(__pthread_alloc_template<dummy>*)pthread_getspecific(key);
|
||||
obj * volatile * my_free_list =
|
||||
a->free_list + FREELIST_INDEX(bytes_left);
|
||||
size_t __bytes_to_get =
|
||||
2 * __total_bytes + _S_round_up(_S_heap_size >> 4);
|
||||
// Try to make use of the left-over piece.
|
||||
if (__bytes_left > 0) {
|
||||
_Pthread_alloc_per_thread_state<_Max_size>* __a =
|
||||
(_Pthread_alloc_per_thread_state<_Max_size>*)
|
||||
pthread_getspecific(_S_key);
|
||||
__obj * volatile * __my_free_list =
|
||||
__a->__free_list + _S_freelist_index(__bytes_left);
|
||||
|
||||
((obj *)start_free) -> free_list_link = *my_free_list;
|
||||
*my_free_list = (obj *)start_free;
|
||||
}
|
||||
# ifdef _SGI_SOURCE
|
||||
// Try to get memory that's aligned on something like a
|
||||
// cache line boundary, so as to avoid parceling out
|
||||
// parts of the same line to different threads and thus
|
||||
// possibly different processors.
|
||||
{
|
||||
const int cache_line_size = 128; // probable upper bound
|
||||
bytes_to_get &= ~(cache_line_size-1);
|
||||
start_free = (char *)memalign(cache_line_size, bytes_to_get);
|
||||
if (0 == start_free) {
|
||||
start_free = (char *)malloc_alloc::allocate(bytes_to_get);
|
||||
}
|
||||
}
|
||||
# else /* !SGI_SOURCE */
|
||||
start_free = (char *)malloc_alloc::allocate(bytes_to_get);
|
||||
((__obj *)_S_start_free) -> __free_list_link = *__my_free_list;
|
||||
*__my_free_list = (__obj *)_S_start_free;
|
||||
}
|
||||
# ifdef _SGI_SOURCE
|
||||
// Try to get memory that's aligned on something like a
|
||||
// cache line boundary, so as to avoid parceling out
|
||||
// parts of the same line to different threads and thus
|
||||
// possibly different processors.
|
||||
{
|
||||
const int __cache_line_size = 128; // probable upper bound
|
||||
__bytes_to_get &= ~(__cache_line_size-1);
|
||||
_S_start_free = (char *)memalign(__cache_line_size, __bytes_to_get);
|
||||
if (0 == _S_start_free) {
|
||||
_S_start_free = (char *)malloc_alloc::allocate(__bytes_to_get);
|
||||
}
|
||||
}
|
||||
# else /* !SGI_SOURCE */
|
||||
_S_start_free = (char *)malloc_alloc::allocate(__bytes_to_get);
|
||||
# endif
|
||||
heap_size += bytes_to_get;
|
||||
end_free = start_free + bytes_to_get;
|
||||
_S_heap_size += __bytes_to_get;
|
||||
_S_end_free = _S_start_free + __bytes_to_get;
|
||||
}
|
||||
}
|
||||
// lock is released here
|
||||
return(chunk_alloc(size, nobjs));
|
||||
return(_S_chunk_alloc(__size, __nobjs));
|
||||
}
|
||||
|
||||
|
||||
/* Returns an object of size n, and optionally adds to size n free list.*/
|
||||
/* We assume that n is properly aligned. */
|
||||
/* We hold the allocation lock. */
|
||||
template <bool dummy>
|
||||
void *__pthread_alloc_template<dummy>
|
||||
::refill(size_t n)
|
||||
/* We assume that n is properly aligned. */
|
||||
/* We hold the allocation lock. */
|
||||
template <size_t _Max_size>
|
||||
void *_Pthread_alloc_per_thread_state<_Max_size>
|
||||
::_M_refill(size_t __n)
|
||||
{
|
||||
int nobjs = 128;
|
||||
char * chunk = chunk_alloc(n, nobjs);
|
||||
obj * volatile * my_free_list;
|
||||
obj * result;
|
||||
obj * current_obj, * next_obj;
|
||||
int i;
|
||||
int __nobjs = 128;
|
||||
char * __chunk =
|
||||
_Pthread_alloc_template<_Max_size>::_S_chunk_alloc(__n, __nobjs);
|
||||
__obj * volatile * __my_free_list;
|
||||
__obj * __result;
|
||||
__obj * __current_obj, * __next_obj;
|
||||
int __i;
|
||||
|
||||
if (1 == nobjs) {
|
||||
return(chunk);
|
||||
if (1 == __nobjs) {
|
||||
return(__chunk);
|
||||
}
|
||||
my_free_list = free_list + FREELIST_INDEX(n);
|
||||
__my_free_list = __free_list
|
||||
+ _Pthread_alloc_template<_Max_size>::_S_freelist_index(__n);
|
||||
|
||||
/* Build free list in chunk */
|
||||
result = (obj *)chunk;
|
||||
*my_free_list = next_obj = (obj *)(chunk + n);
|
||||
for (i = 1; ; i++) {
|
||||
current_obj = next_obj;
|
||||
next_obj = (obj *)((char *)next_obj + n);
|
||||
if (nobjs - 1 == i) {
|
||||
current_obj -> free_list_link = 0;
|
||||
break;
|
||||
} else {
|
||||
current_obj -> free_list_link = next_obj;
|
||||
}
|
||||
__result = (__obj *)__chunk;
|
||||
*__my_free_list = __next_obj = (__obj *)(__chunk + __n);
|
||||
for (__i = 1; ; __i++) {
|
||||
__current_obj = __next_obj;
|
||||
__next_obj = (__obj *)((char *)__next_obj + __n);
|
||||
if (__nobjs - 1 == __i) {
|
||||
__current_obj -> __free_list_link = 0;
|
||||
break;
|
||||
} else {
|
||||
__current_obj -> __free_list_link = __next_obj;
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
return(__result);
|
||||
}
|
||||
|
||||
template <bool dummy>
|
||||
void *__pthread_alloc_template<dummy>
|
||||
::reallocate(void *p, size_t old_sz, size_t new_sz)
|
||||
template <size_t _Max_size>
|
||||
void *_Pthread_alloc_template<_Max_size>
|
||||
::reallocate(void *__p, size_t __old_sz, size_t __new_sz)
|
||||
{
|
||||
void * result;
|
||||
size_t copy_sz;
|
||||
void * __result;
|
||||
size_t __copy_sz;
|
||||
|
||||
if (old_sz > MAX_BYTES && new_sz > MAX_BYTES) {
|
||||
return(realloc(p, new_sz));
|
||||
if (__old_sz > _Max_size
|
||||
&& __new_sz > _Max_size) {
|
||||
return(realloc(__p, __new_sz));
|
||||
}
|
||||
if (ROUND_UP(old_sz) == ROUND_UP(new_sz)) return(p);
|
||||
result = allocate(new_sz);
|
||||
copy_sz = new_sz > old_sz? old_sz : new_sz;
|
||||
memcpy(result, p, copy_sz);
|
||||
deallocate(p, old_sz);
|
||||
return(result);
|
||||
if (_S_round_up(__old_sz) == _S_round_up(__new_sz)) return(__p);
|
||||
__result = allocate(__new_sz);
|
||||
__copy_sz = __new_sz > __old_sz? __old_sz : __new_sz;
|
||||
memcpy(__result, __p, __copy_sz);
|
||||
deallocate(__p, __old_sz);
|
||||
return(__result);
|
||||
}
|
||||
|
||||
template <bool dummy>
|
||||
__pthread_alloc_template<dummy> *
|
||||
__pthread_alloc_template<dummy>::free_allocators = 0;
|
||||
template <size_t _Max_size>
|
||||
_Pthread_alloc_per_thread_state<_Max_size> *
|
||||
_Pthread_alloc_template<_Max_size>::_S_free_per_thread_states = 0;
|
||||
|
||||
template <bool dummy>
|
||||
pthread_key_t __pthread_alloc_template<dummy>::key;
|
||||
template <size_t _Max_size>
|
||||
pthread_key_t _Pthread_alloc_template<_Max_size>::_S_key;
|
||||
|
||||
template <bool dummy>
|
||||
bool __pthread_alloc_template<dummy>::key_initialized = false;
|
||||
template <size_t _Max_size>
|
||||
bool _Pthread_alloc_template<_Max_size>::_S_key_initialized = false;
|
||||
|
||||
template <bool dummy>
|
||||
pthread_mutex_t __pthread_alloc_template<dummy>::chunk_allocator_lock
|
||||
template <size_t _Max_size>
|
||||
pthread_mutex_t _Pthread_alloc_template<_Max_size>::_S_chunk_allocator_lock
|
||||
= PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
template <bool dummy>
|
||||
char *__pthread_alloc_template<dummy>
|
||||
::start_free = 0;
|
||||
template <size_t _Max_size>
|
||||
char *_Pthread_alloc_template<_Max_size>
|
||||
::_S_start_free = 0;
|
||||
|
||||
template <bool dummy>
|
||||
char *__pthread_alloc_template<dummy>
|
||||
::end_free = 0;
|
||||
template <size_t _Max_size>
|
||||
char *_Pthread_alloc_template<_Max_size>
|
||||
::_S_end_free = 0;
|
||||
|
||||
template <bool dummy>
|
||||
size_t __pthread_alloc_template<dummy>
|
||||
::heap_size = 0;
|
||||
template <size_t _Max_size>
|
||||
size_t _Pthread_alloc_template<_Max_size>
|
||||
::_S_heap_size = 0;
|
||||
|
||||
#ifdef __STL_USE_STD_ALLOCATORS
|
||||
|
||||
template <class _Tp>
|
||||
class pthread_allocator {
|
||||
typedef pthread_alloc _S_Alloc; // The underlying allocator.
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
|
||||
template <class _Up> struct rebind {
|
||||
typedef pthread_allocator<_Up> other;
|
||||
};
|
||||
|
||||
pthread_allocator() __STL_NOTHROW {}
|
||||
pthread_allocator(const pthread_allocator& a) __STL_NOTHROW {}
|
||||
template <class _Up> pthread_allocator(const pthread_allocator<_Up>&)
|
||||
__STL_NOTHROW {}
|
||||
~pthread_allocator() __STL_NOTHROW {}
|
||||
|
||||
pointer address(reference __x) const { return &__x; }
|
||||
const_pointer address(const_reference __x) const { return &__x; }
|
||||
|
||||
// __n is permitted to be 0. The C++ standard says nothing about what
|
||||
// the return value is when __n == 0.
|
||||
_Tp* allocate(size_type __n, const void* = 0) {
|
||||
return __n != 0 ? static_cast<_Tp*>(_S_Alloc::allocate(__n * sizeof(_Tp)))
|
||||
: 0;
|
||||
}
|
||||
|
||||
// p is not permitted to be a null pointer.
|
||||
void deallocate(pointer __p, size_type __n)
|
||||
{ _S_Alloc::deallocate(__p, __n * sizeof(_Tp)); }
|
||||
|
||||
size_type max_size() const __STL_NOTHROW
|
||||
{ return size_t(-1) / sizeof(_Tp); }
|
||||
|
||||
void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }
|
||||
void destroy(pointer _p) { _p->~_Tp(); }
|
||||
};
|
||||
|
||||
template<>
|
||||
class pthread_allocator<void> {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef void* pointer;
|
||||
typedef const void* const_pointer;
|
||||
typedef void value_type;
|
||||
|
||||
template <class _Up> struct rebind {
|
||||
typedef pthread_allocator<_Up> other;
|
||||
};
|
||||
};
|
||||
|
||||
template <size_t _Max_size>
|
||||
inline bool operator==(const _Pthread_alloc_template<_Max_size>&,
|
||||
const _Pthread_alloc_template<_Max_size>&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline bool operator==(const pthread_allocator<_T1>&,
|
||||
const pthread_allocator<_T2>& a2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline bool operator!=(const pthread_allocator<_T1>&,
|
||||
const pthread_allocator<_T2>&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Max_size>
|
||||
struct _Alloc_traits<_Tp, _Pthread_alloc_template<_Max_size> >
|
||||
{
|
||||
static const bool _S_instanceless = true;
|
||||
typedef simple_alloc<_Tp, _Pthread_alloc_template<_Max_size> > _Alloc_type;
|
||||
typedef __allocator<_Tp, _Pthread_alloc_template<_Max_size> >
|
||||
allocator_type;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Up, size_t _Max>
|
||||
struct _Alloc_traits<_Tp, __allocator<_Up, _Pthread_alloc_template<_Max> > >
|
||||
{
|
||||
static const bool _S_instanceless = true;
|
||||
typedef simple_alloc<_Tp, _Pthread_alloc_template<_Max> > _Alloc_type;
|
||||
typedef __allocator<_Tp, _Pthread_alloc_template<_Max> > allocator_type;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct _Alloc_traits<_Tp, pthread_allocator<_Up> >
|
||||
{
|
||||
static const bool _S_instanceless = true;
|
||||
typedef simple_alloc<_Tp, _Pthread_alloc_template<> > _Alloc_type;
|
||||
typedef pthread_allocator<_Tp> allocator_type;
|
||||
};
|
||||
|
||||
|
||||
#endif /* __STL_USE_STD_ALLOCATORS */
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
||||
|
@ -18,8 +18,8 @@
|
||||
|
||||
#ifdef __STL_USE_NAMESPACES
|
||||
|
||||
using __STD::__pthread_alloc_template;
|
||||
using __STL::pthread_alloc;
|
||||
using __STD::_Pthread_alloc_template;
|
||||
using __STD::pthread_alloc;
|
||||
|
||||
#endif /* __STL_USE_NAMESPACES */
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
#define __SGI_STL_ROPE
|
||||
|
||||
#include <stl_algobase.h>
|
||||
#include <tempbuf.h>
|
||||
#include <stl_tempbuf.h>
|
||||
#include <stl_algo.h>
|
||||
#include <stl_function.h>
|
||||
#include <stl_numeric.h>
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,7 @@
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1996
|
||||
* Copyright (c) 1996-1998
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
@ -58,381 +58,465 @@
|
||||
|
||||
__STL_BEGIN_NAMESPACE
|
||||
|
||||
template <class ForwardIterator1, class ForwardIterator2, class T>
|
||||
inline void __iter_swap(ForwardIterator1 a, ForwardIterator2 b, T*) {
|
||||
T tmp = *a;
|
||||
*a = *b;
|
||||
*b = tmp;
|
||||
// swap and iter_swap
|
||||
|
||||
template <class _ForwardIter1, class _ForwardIter2, class _Tp>
|
||||
inline void __iter_swap(_ForwardIter1 __a, _ForwardIter2 __b, _Tp*) {
|
||||
_Tp __tmp = *__a;
|
||||
*__a = *__b;
|
||||
*__b = __tmp;
|
||||
}
|
||||
|
||||
template <class ForwardIterator1, class ForwardIterator2>
|
||||
inline void iter_swap(ForwardIterator1 a, ForwardIterator2 b) {
|
||||
__iter_swap(a, b, value_type(a));
|
||||
template <class _ForwardIter1, class _ForwardIter2>
|
||||
inline void iter_swap(_ForwardIter1 __a, _ForwardIter2 __b) {
|
||||
__iter_swap(__a, __b, __VALUE_TYPE(__a));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void swap(T& a, T& b) {
|
||||
T tmp = a;
|
||||
a = b;
|
||||
b = tmp;
|
||||
template <class _Tp>
|
||||
inline void swap(_Tp& __a, _Tp& __b) {
|
||||
_Tp __tmp = __a;
|
||||
__a = __b;
|
||||
__b = __tmp;
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// min and max
|
||||
|
||||
#ifndef __BORLANDC__
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
template <class T>
|
||||
inline const T& min(const T& a, const T& b) {
|
||||
return b < a ? b : a;
|
||||
template <class _Tp>
|
||||
inline const _Tp& min(const _Tp& __a, const _Tp& __b) {
|
||||
return __b < __a ? __b : __a;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const T& max(const T& a, const T& b) {
|
||||
return a < b ? b : a;
|
||||
template <class _Tp>
|
||||
inline const _Tp& max(const _Tp& __a, const _Tp& __b) {
|
||||
return __a < __b ? __b : __a;
|
||||
}
|
||||
|
||||
#endif /* __BORLANDC__ */
|
||||
|
||||
template <class T, class Compare>
|
||||
inline const T& min(const T& a, const T& b, Compare comp) {
|
||||
return comp(b, a) ? b : a;
|
||||
template <class _Tp, class _Compare>
|
||||
inline const _Tp& min(const _Tp& __a, const _Tp& __b, _Compare __comp) {
|
||||
return __comp(__b, __a) ? __b : __a;
|
||||
}
|
||||
|
||||
template <class T, class Compare>
|
||||
inline const T& max(const T& a, const T& b, Compare comp) {
|
||||
return comp(a, b) ? b : a;
|
||||
template <class _Tp, class _Compare>
|
||||
inline const _Tp& max(const _Tp& __a, const _Tp& __b, _Compare __comp) {
|
||||
return __comp(__a, __b) ? __b : __a;
|
||||
}
|
||||
|
||||
template <class InputIterator, class OutputIterator>
|
||||
inline OutputIterator __copy(InputIterator first, InputIterator last,
|
||||
OutputIterator result, input_iterator_tag)
|
||||
//--------------------------------------------------
|
||||
// copy
|
||||
|
||||
// All of these auxiliary functions serve two purposes. (1) Replace
|
||||
// calls to copy with memmove whenever possible. (Memmove, not memcpy,
|
||||
// because the input and output ranges are permitted to overlap.)
|
||||
// (2) If we're using random access iterators, then write the loop as
|
||||
// a for loop with an explicit count. The auxiliary class __copy_dispatch
|
||||
// is a workaround for compilers that don't support partial ordering of
|
||||
// function templates.
|
||||
|
||||
template <class _InputIter, class _OutputIter, class _Distance>
|
||||
inline _OutputIter __copy(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result,
|
||||
input_iterator_tag, _Distance*)
|
||||
{
|
||||
for ( ; first != last; ++result, ++first)
|
||||
*result = *first;
|
||||
return result;
|
||||
for ( ; __first != __last; ++__result, ++__first)
|
||||
*__result = *__first;
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class OutputIterator, class Distance>
|
||||
inline OutputIterator
|
||||
__copy_d(RandomAccessIterator first, RandomAccessIterator last,
|
||||
OutputIterator result, Distance*)
|
||||
template <class _RandomAccessIter, class _OutputIter, class _Distance>
|
||||
inline _OutputIter
|
||||
__copy(_RandomAccessIter __first, _RandomAccessIter __last,
|
||||
_OutputIter __result, random_access_iterator_tag, _Distance*)
|
||||
{
|
||||
for (Distance n = last - first; n > 0; --n, ++result, ++first)
|
||||
*result = *first;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class OutputIterator>
|
||||
inline OutputIterator
|
||||
__copy(RandomAccessIterator first, RandomAccessIterator last,
|
||||
OutputIterator result, random_access_iterator_tag)
|
||||
{
|
||||
return __copy_d(first, last, result, distance_type(first));
|
||||
}
|
||||
|
||||
template <class InputIterator, class OutputIterator>
|
||||
struct __copy_dispatch
|
||||
{
|
||||
OutputIterator operator()(InputIterator first, InputIterator last,
|
||||
OutputIterator result) {
|
||||
return __copy(first, last, result, iterator_category(first));
|
||||
for (_Distance __n = __last - __first; __n > 0; --__n) {
|
||||
*__result = *__first;
|
||||
++__first;
|
||||
++__result;
|
||||
}
|
||||
};
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _Tp*
|
||||
__copy_trivial(const _Tp* __first, const _Tp* __last, _Tp* __result) {
|
||||
memmove(__result, __first, sizeof(_Tp) * (__last - __first));
|
||||
return __result + (__last - __first);
|
||||
}
|
||||
|
||||
#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
|
||||
|
||||
template <class T>
|
||||
inline T* __copy_t(const T* first, const T* last, T* result, __true_type) {
|
||||
memmove(result, first, sizeof(T) * (last - first));
|
||||
return result + (last - first);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T* __copy_t(const T* first, const T* last, T* result, __false_type) {
|
||||
return __copy_d(first, last, result, (ptrdiff_t*) 0);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct __copy_dispatch<T*, T*>
|
||||
{
|
||||
T* operator()(T* first, T* last, T* result) {
|
||||
typedef typename __type_traits<T>::has_trivial_assignment_operator t;
|
||||
return __copy_t(first, last, result, t());
|
||||
template <class _InputIter, class _OutputIter, class _BoolType>
|
||||
struct __copy_dispatch {
|
||||
static _OutputIter copy(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result) {
|
||||
typedef typename iterator_traits<_InputIter>::iterator_category _Category;
|
||||
typedef typename iterator_traits<_InputIter>::difference_type _Distance;
|
||||
return __copy(__first, __last, __result, _Category(), (_Distance*) 0);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct __copy_dispatch<const T*, T*>
|
||||
template <class _Tp>
|
||||
struct __copy_dispatch<_Tp*, _Tp*, __true_type>
|
||||
{
|
||||
T* operator()(const T* first, const T* last, T* result) {
|
||||
typedef typename __type_traits<T>::has_trivial_assignment_operator t;
|
||||
return __copy_t(first, last, result, t());
|
||||
static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) {
|
||||
return __copy_trivial(__first, __last, __result);
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __copy_dispatch<const _Tp*, _Tp*, __true_type>
|
||||
{
|
||||
static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) {
|
||||
return __copy_trivial(__first, __last, __result);
|
||||
}
|
||||
};
|
||||
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter copy(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result) {
|
||||
typedef typename iterator_traits<_InputIter>::value_type _Tp;
|
||||
typedef typename __type_traits<_Tp>::has_trivial_assignment_operator
|
||||
_Trivial;
|
||||
return __copy_dispatch<_InputIter, _OutputIter, _Trivial>
|
||||
::copy(__first, __last, __result);
|
||||
}
|
||||
|
||||
#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */
|
||||
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter copy(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result)
|
||||
{
|
||||
return __copy(__first, __last, __result,
|
||||
__ITERATOR_CATEGORY(__first),
|
||||
__DISTANCE_TYPE(__first));
|
||||
}
|
||||
|
||||
inline char* copy(const char* __first, const char* __last, char* __result) {
|
||||
memmove(__result, __first, __last - __first);
|
||||
return __result + (__last - __first);
|
||||
}
|
||||
|
||||
inline wchar_t* copy(const wchar_t* __first, const wchar_t* __last,
|
||||
wchar_t* __result) {
|
||||
memmove(__result, __first, sizeof(wchar_t) * (__last - __first));
|
||||
return __result + (__last - __first);
|
||||
}
|
||||
|
||||
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
|
||||
|
||||
template <class InputIterator, class OutputIterator>
|
||||
inline OutputIterator copy(InputIterator first, InputIterator last,
|
||||
OutputIterator result)
|
||||
//--------------------------------------------------
|
||||
// copy_backward
|
||||
|
||||
template <class _BidirectionalIter1, class _BidirectionalIter2,
|
||||
class _Distance>
|
||||
inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first,
|
||||
_BidirectionalIter1 __last,
|
||||
_BidirectionalIter2 __result,
|
||||
bidirectional_iterator_tag,
|
||||
_Distance*)
|
||||
{
|
||||
return __copy_dispatch<InputIterator,OutputIterator>()(first, last, result);
|
||||
while (__first != __last)
|
||||
*--__result = *--__last;
|
||||
return __result;
|
||||
}
|
||||
|
||||
inline char* copy(const char* first, const char* last, char* result) {
|
||||
memmove(result, first, last - first);
|
||||
return result + (last - first);
|
||||
template <class _RandomAccessIter, class _BidirectionalIter, class _Distance>
|
||||
inline _BidirectionalIter __copy_backward(_RandomAccessIter __first,
|
||||
_RandomAccessIter __last,
|
||||
_BidirectionalIter __result,
|
||||
random_access_iterator_tag,
|
||||
_Distance*)
|
||||
{
|
||||
for (_Distance __n = __last - __first; __n > 0; --__n)
|
||||
*--__result = *--__last;
|
||||
return __result;
|
||||
}
|
||||
|
||||
inline wchar_t* copy(const wchar_t* first, const wchar_t* last,
|
||||
wchar_t* result) {
|
||||
memmove(result, first, sizeof(wchar_t) * (last - first));
|
||||
return result + (last - first);
|
||||
}
|
||||
#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
|
||||
|
||||
template <class BidirectionalIterator1, class BidirectionalIterator2>
|
||||
inline BidirectionalIterator2 __copy_backward(BidirectionalIterator1 first,
|
||||
BidirectionalIterator1 last,
|
||||
BidirectionalIterator2 result) {
|
||||
while (first != last) *--result = *--last;
|
||||
return result;
|
||||
}
|
||||
// This dispatch class is a workaround for compilers that do not
|
||||
// have partial ordering of function templates. All we're doing is
|
||||
// creating a specialization so that we can turn a call to copy_backward
|
||||
// into a memmove whenever possible.
|
||||
|
||||
|
||||
template <class BidirectionalIterator1, class BidirectionalIterator2>
|
||||
template <class _BidirectionalIter1, class _BidirectionalIter2,
|
||||
class _BoolType>
|
||||
struct __copy_backward_dispatch
|
||||
{
|
||||
BidirectionalIterator2 operator()(BidirectionalIterator1 first,
|
||||
BidirectionalIterator1 last,
|
||||
BidirectionalIterator2 result) {
|
||||
return __copy_backward(first, last, result);
|
||||
typedef typename iterator_traits<_BidirectionalIter1>::iterator_category
|
||||
_Cat;
|
||||
typedef typename iterator_traits<_BidirectionalIter1>::difference_type
|
||||
_Distance;
|
||||
|
||||
static _BidirectionalIter2 copy(_BidirectionalIter1 __first,
|
||||
_BidirectionalIter1 __last,
|
||||
_BidirectionalIter2 __result) {
|
||||
return __copy_backward(__first, __last, __result, _Cat(), (_Distance*) 0);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
|
||||
template <class _Tp>
|
||||
struct __copy_backward_dispatch<_Tp*, _Tp*, __true_type>
|
||||
{
|
||||
static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) {
|
||||
const ptrdiff_t _Num = __last - __first;
|
||||
memmove(__result - _Num, __first, sizeof(_Tp) * _Num);
|
||||
return __result - _Num;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline T* __copy_backward_t(const T* first, const T* last, T* result,
|
||||
__true_type) {
|
||||
const ptrdiff_t N = last - first;
|
||||
memmove(result - N, first, sizeof(T) * N);
|
||||
return result - N;
|
||||
template <class _Tp>
|
||||
struct __copy_backward_dispatch<const _Tp*, _Tp*, __true_type>
|
||||
{
|
||||
static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) {
|
||||
return __copy_backward_dispatch<_Tp*, _Tp*, __true_type>
|
||||
::copy(__first, __last, __result);
|
||||
}
|
||||
};
|
||||
|
||||
template <class _BI1, class _BI2>
|
||||
inline _BI2 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) {
|
||||
typedef typename __type_traits<typename iterator_traits<_BI2>::value_type>
|
||||
::has_trivial_assignment_operator
|
||||
_Trivial;
|
||||
return __copy_backward_dispatch<_BI1, _BI2, _Trivial>
|
||||
::copy(__first, __last, __result);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T* __copy_backward_t(const T* first, const T* last, T* result,
|
||||
__false_type) {
|
||||
return __copy_backward(first, last, result);
|
||||
#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */
|
||||
|
||||
template <class _BI1, class _BI2>
|
||||
inline _BI2 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) {
|
||||
return __copy_backward(__first, __last, __result,
|
||||
__ITERATOR_CATEGORY(__first),
|
||||
__DISTANCE_TYPE(__first));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct __copy_backward_dispatch<T*, T*>
|
||||
{
|
||||
T* operator()(T* first, T* last, T* result) {
|
||||
typedef typename __type_traits<T>::has_trivial_assignment_operator t;
|
||||
return __copy_backward_t(first, last, result, t());
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct __copy_backward_dispatch<const T*, T*>
|
||||
{
|
||||
T* operator()(const T* first, const T* last, T* result) {
|
||||
typedef typename __type_traits<T>::has_trivial_assignment_operator t;
|
||||
return __copy_backward_t(first, last, result, t());
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
|
||||
|
||||
template <class BidirectionalIterator1, class BidirectionalIterator2>
|
||||
inline BidirectionalIterator2 copy_backward(BidirectionalIterator1 first,
|
||||
BidirectionalIterator1 last,
|
||||
BidirectionalIterator2 result) {
|
||||
return __copy_backward_dispatch<BidirectionalIterator1,
|
||||
BidirectionalIterator2>()(first, last,
|
||||
result);
|
||||
//--------------------------------------------------
|
||||
// copy_n (not part of the C++ standard)
|
||||
|
||||
template <class _InputIter, class _Size, class _OutputIter>
|
||||
pair<_InputIter, _OutputIter> __copy_n(_InputIter __first, _Size __count,
|
||||
_OutputIter __result,
|
||||
input_iterator_tag) {
|
||||
for ( ; __count > 0; --__count) {
|
||||
*__result = *__first;
|
||||
++__first;
|
||||
++__result;
|
||||
}
|
||||
return pair<_InputIter, _OutputIter>(__first, __result);
|
||||
}
|
||||
|
||||
template <class InputIterator, class Size, class OutputIterator>
|
||||
pair<InputIterator, OutputIterator> __copy_n(InputIterator first, Size count,
|
||||
OutputIterator result,
|
||||
input_iterator_tag) {
|
||||
for ( ; count > 0; --count, ++first, ++result)
|
||||
*result = *first;
|
||||
return pair<InputIterator, OutputIterator>(first, result);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class Size, class OutputIterator>
|
||||
inline pair<RandomAccessIterator, OutputIterator>
|
||||
__copy_n(RandomAccessIterator first, Size count,
|
||||
OutputIterator result,
|
||||
template <class _RAIter, class _Size, class _OutputIter>
|
||||
inline pair<_RAIter, _OutputIter>
|
||||
__copy_n(_RAIter __first, _Size __count,
|
||||
_OutputIter __result,
|
||||
random_access_iterator_tag) {
|
||||
RandomAccessIterator last = first + count;
|
||||
return pair<RandomAccessIterator, OutputIterator>(last,
|
||||
copy(first, last, result));
|
||||
_RAIter __last = __first + __count;
|
||||
return pair<_RAIter, _OutputIter>(__last, copy(__first, __last, __result));
|
||||
}
|
||||
|
||||
template <class InputIterator, class Size, class OutputIterator>
|
||||
inline pair<InputIterator, OutputIterator>
|
||||
copy_n(InputIterator first, Size count,
|
||||
OutputIterator result) {
|
||||
return __copy_n(first, count, result, iterator_category(first));
|
||||
template <class _InputIter, class _Size, class _OutputIter>
|
||||
inline pair<_InputIter, _OutputIter>
|
||||
__copy_n(_InputIter __first, _Size __count, _OutputIter __result) {
|
||||
return __copy_n(__first, __count, __result,
|
||||
__ITERATOR_CATEGORY(__first));
|
||||
}
|
||||
|
||||
template <class ForwardIterator, class T>
|
||||
void fill(ForwardIterator first, ForwardIterator last, const T& value) {
|
||||
for ( ; first != last; ++first)
|
||||
*first = value;
|
||||
template <class _InputIter, class _Size, class _OutputIter>
|
||||
inline pair<_InputIter, _OutputIter>
|
||||
copy_n(_InputIter __first, _Size __count, _OutputIter __result) {
|
||||
return __copy_n(__first, __count, __result);
|
||||
}
|
||||
|
||||
template <class OutputIterator, class Size, class T>
|
||||
OutputIterator fill_n(OutputIterator first, Size n, const T& value) {
|
||||
for ( ; n > 0; --n, ++first)
|
||||
*first = value;
|
||||
return first;
|
||||
//--------------------------------------------------
|
||||
// fill and fill_n
|
||||
|
||||
|
||||
template <class _ForwardIter, class _Tp>
|
||||
void fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __value) {
|
||||
for ( ; __first != __last; ++__first)
|
||||
*__first = __value;
|
||||
}
|
||||
|
||||
template <class InputIterator1, class InputIterator2>
|
||||
pair<InputIterator1, InputIterator2> mismatch(InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2) {
|
||||
while (first1 != last1 && *first1 == *first2) {
|
||||
++first1;
|
||||
++first2;
|
||||
template <class _OutputIter, class _Size, class _Tp>
|
||||
_OutputIter fill_n(_OutputIter __first, _Size __n, const _Tp& __value) {
|
||||
for ( ; __n > 0; --__n, ++__first)
|
||||
*__first = __value;
|
||||
return __first;
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// equal and mismatch
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
|
||||
_InputIter1 __last1,
|
||||
_InputIter2 __first2) {
|
||||
while (__first1 != __last1 && *__first1 == *__first2) {
|
||||
++__first1;
|
||||
++__first2;
|
||||
}
|
||||
return pair<InputIterator1, InputIterator2>(first1, first2);
|
||||
return pair<_InputIter1, _InputIter2>(__first1, __first2);
|
||||
}
|
||||
|
||||
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
|
||||
pair<InputIterator1, InputIterator2> mismatch(InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
BinaryPredicate binary_pred) {
|
||||
while (first1 != last1 && binary_pred(*first1, *first2)) {
|
||||
++first1;
|
||||
++first2;
|
||||
template <class _InputIter1, class _InputIter2, class _BinaryPredicate>
|
||||
pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
|
||||
_InputIter1 __last1,
|
||||
_InputIter2 __first2,
|
||||
_BinaryPredicate __binary_pred) {
|
||||
while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) {
|
||||
++__first1;
|
||||
++__first2;
|
||||
}
|
||||
return pair<InputIterator1, InputIterator2>(first1, first2);
|
||||
return pair<_InputIter1, _InputIter2>(__first1, __first2);
|
||||
}
|
||||
|
||||
template <class InputIterator1, class InputIterator2>
|
||||
inline bool equal(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2) {
|
||||
for ( ; first1 != last1; ++first1, ++first2)
|
||||
if (*first1 != *first2)
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
inline bool equal(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2) {
|
||||
for ( ; __first1 != __last1; ++__first1, ++__first2)
|
||||
if (*__first1 != *__first2)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
|
||||
inline bool equal(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, BinaryPredicate binary_pred) {
|
||||
for ( ; first1 != last1; ++first1, ++first2)
|
||||
if (!binary_pred(*first1, *first2))
|
||||
template <class _InputIter1, class _InputIter2, class _BinaryPredicate>
|
||||
inline bool equal(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _BinaryPredicate __binary_pred) {
|
||||
for ( ; __first1 != __last1; ++__first1, ++__first2)
|
||||
if (!__binary_pred(*__first1, *__first2))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class InputIterator1, class InputIterator2>
|
||||
bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2) {
|
||||
for ( ; first1 != last1 && first2 != last2; ++first1, ++first2) {
|
||||
if (*first1 < *first2)
|
||||
//--------------------------------------------------
|
||||
// lexicographical_compare and lexicographical_compare_3way.
|
||||
// (the latter is not part of the C++ standard.)
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2) {
|
||||
for ( ; __first1 != __last1 && __first2 != __last2
|
||||
; ++__first1, ++__first2) {
|
||||
if (*__first1 < *__first2)
|
||||
return true;
|
||||
if (*first2 < *first1)
|
||||
if (*__first2 < *__first1)
|
||||
return false;
|
||||
}
|
||||
return first1 == last1 && first2 != last2;
|
||||
return __first1 == __last1 && __first2 != __last2;
|
||||
}
|
||||
|
||||
template <class InputIterator1, class InputIterator2, class Compare>
|
||||
bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2,
|
||||
Compare comp) {
|
||||
for ( ; first1 != last1 && first2 != last2; ++first1, ++first2) {
|
||||
if (comp(*first1, *first2))
|
||||
template <class _InputIter1, class _InputIter2, class _Compare>
|
||||
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_Compare __comp) {
|
||||
for ( ; __first1 != __last1 && __first2 != __last2
|
||||
; ++__first1, ++__first2) {
|
||||
if (__comp(*__first1, *__first2))
|
||||
return true;
|
||||
if (comp(*first2, *first1))
|
||||
if (__comp(*__first2, *__first1))
|
||||
return false;
|
||||
}
|
||||
return first1 == last1 && first2 != last2;
|
||||
return __first1 == __last1 && __first2 != __last2;
|
||||
}
|
||||
|
||||
inline bool
|
||||
lexicographical_compare(const unsigned char* first1,
|
||||
const unsigned char* last1,
|
||||
const unsigned char* first2,
|
||||
const unsigned char* last2)
|
||||
lexicographical_compare(const unsigned char* __first1,
|
||||
const unsigned char* __last1,
|
||||
const unsigned char* __first2,
|
||||
const unsigned char* __last2)
|
||||
{
|
||||
const size_t len1 = last1 - first1;
|
||||
const size_t len2 = last2 - first2;
|
||||
const int result = memcmp(first1, first2, min(len1, len2));
|
||||
return result != 0 ? result < 0 : len1 < len2;
|
||||
const size_t __len1 = __last1 - __first1;
|
||||
const size_t __len2 = __last2 - __first2;
|
||||
const int __result = memcmp(__first1, __first2, min(__len1, __len2));
|
||||
return __result != 0 ? __result < 0 : __len1 < __len2;
|
||||
}
|
||||
|
||||
inline bool lexicographical_compare(const char* first1, const char* last1,
|
||||
const char* first2, const char* last2)
|
||||
inline bool lexicographical_compare(const char* __first1, const char* __last1,
|
||||
const char* __first2, const char* __last2)
|
||||
{
|
||||
#if CHAR_MAX == SCHAR_MAX
|
||||
return lexicographical_compare((const signed char*) first1,
|
||||
(const signed char*) last1,
|
||||
(const signed char*) first2,
|
||||
(const signed char*) last2);
|
||||
#else
|
||||
return lexicographical_compare((const unsigned char*) first1,
|
||||
(const unsigned char*) last1,
|
||||
(const unsigned char*) first2,
|
||||
(const unsigned char*) last2);
|
||||
#endif
|
||||
return lexicographical_compare((const signed char*) __first1,
|
||||
(const signed char*) __last1,
|
||||
(const signed char*) __first2,
|
||||
(const signed char*) __last2);
|
||||
#else /* CHAR_MAX == SCHAR_MAX */
|
||||
return lexicographical_compare((const unsigned char*) __first1,
|
||||
(const unsigned char*) __last1,
|
||||
(const unsigned char*) __first2,
|
||||
(const unsigned char*) __last2);
|
||||
#endif /* CHAR_MAX == SCHAR_MAX */
|
||||
}
|
||||
|
||||
template <class InputIterator1, class InputIterator2>
|
||||
int lexicographical_compare_3way(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2)
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2)
|
||||
{
|
||||
while (first1 != last1 && first2 != last2) {
|
||||
if (*first1 < *first2) return -1;
|
||||
if (*first2 < *first1) return 1;
|
||||
++first1; ++first2;
|
||||
while (__first1 != __last1 && __first2 != __last2) {
|
||||
if (*__first1 < *__first2)
|
||||
return -1;
|
||||
if (*__first2 < *__first1)
|
||||
return 1;
|
||||
++__first1;
|
||||
++__first2;
|
||||
}
|
||||
if (first2 == last2) {
|
||||
return !(first1 == last1);
|
||||
} else {
|
||||
if (__first2 == __last2) {
|
||||
return !(__first1 == __last1);
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
inline int
|
||||
lexicographical_compare_3way(const unsigned char* first1,
|
||||
const unsigned char* last1,
|
||||
const unsigned char* first2,
|
||||
const unsigned char* last2)
|
||||
__lexicographical_compare_3way(const unsigned char* __first1,
|
||||
const unsigned char* __last1,
|
||||
const unsigned char* __first2,
|
||||
const unsigned char* __last2)
|
||||
{
|
||||
const ptrdiff_t len1 = last1 - first1;
|
||||
const ptrdiff_t len2 = last2 - first2;
|
||||
const int result = memcmp(first1, first2, min(len1, len2));
|
||||
return result != 0 ? result : (len1 == len2 ? 0 : (len1 < len2 ? -1 : 1));
|
||||
const ptrdiff_t __len1 = __last1 - __first1;
|
||||
const ptrdiff_t __len2 = __last2 - __first2;
|
||||
const int __result = memcmp(__first1, __first2, min(__len1, __len2));
|
||||
return __result != 0 ? __result
|
||||
: (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
|
||||
}
|
||||
|
||||
inline int lexicographical_compare_3way(const char* first1, const char* last1,
|
||||
const char* first2, const char* last2)
|
||||
inline int
|
||||
__lexicographical_compare_3way(const char* __first1, const char* __last1,
|
||||
const char* __first2, const char* __last2)
|
||||
{
|
||||
#if CHAR_MAX == SCHAR_MAX
|
||||
return lexicographical_compare_3way(
|
||||
(const signed char*) first1,
|
||||
(const signed char*) last1,
|
||||
(const signed char*) first2,
|
||||
(const signed char*) last2);
|
||||
return __lexicographical_compare_3way(
|
||||
(const signed char*) __first1,
|
||||
(const signed char*) __last1,
|
||||
(const signed char*) __first2,
|
||||
(const signed char*) __last2);
|
||||
#else
|
||||
return lexicographical_compare_3way((const unsigned char*) first1,
|
||||
(const unsigned char*) last1,
|
||||
(const unsigned char*) first2,
|
||||
(const unsigned char*) last2);
|
||||
return __lexicographical_compare_3way((const unsigned char*) __first1,
|
||||
(const unsigned char*) __last1,
|
||||
(const unsigned char*) __first2,
|
||||
(const unsigned char*) __last2);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2)
|
||||
{
|
||||
return __lexicographical_compare_3way(__first1, __last1, __first2, __last2);
|
||||
}
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
||||
#endif /* __SGI_STL_INTERNAL_ALGOBASE_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -27,57 +27,89 @@
|
||||
#ifndef __STL_CONFIG_H
|
||||
# define __STL_CONFIG_H
|
||||
|
||||
// What this file does.
|
||||
// (1) Defines bool, true, and false if the compiler doesn't do so already.
|
||||
// (2) Defines __STL_NO_DRAND48 if the compiler's standard library does
|
||||
// not support the drand48() function.
|
||||
// (3) Defines __STL_STATIC_TEMPLATE_MEMBER_BUG if the compiler can't
|
||||
// handle static members of template classes.
|
||||
// (4) Defines 'typename' as a null macro if the compiler does not support
|
||||
// the typename keyword.
|
||||
// (5) Defines __STL_CLASS_PARTIAL_SPECIALIZATION if the compiler
|
||||
// supports partial specialization of class templates.
|
||||
// (6) Defines __STL_FUNCTION_TMPL_PARTIAL_ORDER if the compiler supports
|
||||
// partial ordering of function templates (a.k.a partial specialization
|
||||
// of function templates.
|
||||
// (7) Defines __STL_EXPLICIT_FUNCTION_TMPL_ARGS if the compiler
|
||||
// supports calling a function template by providing its template
|
||||
// arguments explicitly.
|
||||
// (8) Defines __STL_MEMBER_TEMPLATES if the compiler supports
|
||||
// template members of classes.
|
||||
// (9) Defines 'explicit' as a null macro if the compiler does not support
|
||||
// the explicit keyword.
|
||||
// (10) Defines __STL_LIMITED_DEFAULT_TEMPLATES if the compiler is
|
||||
// unable to handle default template parameters that depend on
|
||||
// previous template parameters.
|
||||
// (11) Defines __STL_NON_TYPE_TMPL_PARAM_BUG if the compiler has
|
||||
// trouble performing function template argument deduction for
|
||||
// non-type template parameters.
|
||||
// (12) Defines __SGI_STL_NO_ARROW_OPERATOR if the compiler is unable
|
||||
// to support the -> operator for iterators.
|
||||
// (13) Defines __STL_USE_EXCEPTIONS if the compiler (in the current
|
||||
// compilation mode) supports exceptions.
|
||||
// (14) Define __STL_USE_NAMESPACES if we're putting the STL into a
|
||||
// namespace.
|
||||
// (15) Defines __STL_SGI_THREADS if this is being compiled on an SGI
|
||||
// compiler, and if the user hasn't selected pthreads or no threads
|
||||
// instead.
|
||||
// (16) Defines __STL_WIN32THREADS if this is being compiled on a
|
||||
// WIN32 compiler in multithreaded mode.
|
||||
// (17) Define namespace-related macros (__STD, __STL_BEGIN_NAMESPACE, etc.)
|
||||
// apropriately.
|
||||
// (18) Define exception-related macros (__STL_TRY, __STL_UNWIND, etc.)
|
||||
// appropriately.
|
||||
// (19) Defines __stl_assert either as a test or as a null macro,
|
||||
// depending on whether or not __STL_ASSERTIONS is defined.
|
||||
// Flags:
|
||||
// * __STL_NO_BOOL: defined if the compiler doesn't have bool as a builtin
|
||||
// type.
|
||||
// * __STL_HAS_WCHAR_T: defined if the compier has wchar_t as a builtin type.
|
||||
// * __STL_NO_DRAND48: defined if the compiler doesn't have the drand48
|
||||
// function.
|
||||
// * __STL_STATIC_TEMPLATE_MEMBER_BUG: defined if the compiler can't handle
|
||||
// static members of template classes.
|
||||
// * __STL_CLASS_PARTIAL_SPECIALIZATION: defined if the compiler supports
|
||||
// partial specialization of template classes.
|
||||
// * __STL_PARTIAL_SPECIALIZATION_SYNTAX: defined if the compiler
|
||||
// supports partial specialization syntax for full specialization of
|
||||
// class templates. (Even if it doesn't actually support partial
|
||||
// specialization itself.)
|
||||
// * __STL_FUNCTION_TMPL_PARTIAL_ORDER: defined if the compiler supports
|
||||
// partial ordering of function templates. (a.k.a partial specialization
|
||||
// of function templates.)
|
||||
// * __STL_MEMBER_TEMPLATES: defined if the compiler supports template
|
||||
// member functions of classes.
|
||||
// * __STL_MEMBER_TEMPLATE_CLASSES: defined if the compiler supports
|
||||
// nested classes that are member templates of other classes.
|
||||
// * __STL_EXPLICIT_FUNCTION_TMPL_ARGS: defined if the compiler
|
||||
// supports calling a function template by providing its template
|
||||
// arguments explicitly.
|
||||
// * __STL_LIMITED_DEFAULT_TEMPLATES: defined if the compiler is unable
|
||||
// to handle default template parameters that depend on previous template
|
||||
// parameters.
|
||||
// * __STL_NON_TYPE_TMPL_PARAM_BUG: defined if the compiler has trouble with
|
||||
// function template argument deduction for non-type template parameters.
|
||||
// * __SGI_STL_NO_ARROW_OPERATOR: defined if the compiler is unable
|
||||
// to support the -> operator for iterators.
|
||||
// * __STL_USE_EXCEPTIONS: defined if the compiler (in the current compilation
|
||||
// mode) supports exceptions.
|
||||
// * __STL_USE_NAMESPACES: defined if the compiler has the necessary
|
||||
// support for namespaces.
|
||||
// * __STL_NO_EXCEPTION_HEADER: defined if the compiler does not have a
|
||||
// standard-conforming header <exception>.
|
||||
// * __STL_SGI_THREADS: defined if this is being compiled for an SGI IRIX
|
||||
// system in multithreaded mode, using native SGI threads instead of
|
||||
// pthreads.
|
||||
// * __STL_WIN32THREADS: defined if this is being compiled on a WIN32
|
||||
// compiler in multithreaded mode.
|
||||
// * __STL_LONG_LONG if the compiler has long long and unsigned long long
|
||||
// types. (They're not in the C++ standard, but they are expected to be
|
||||
// included in the forthcoming C9X standard.)
|
||||
|
||||
|
||||
// User-settable macros that control compilation:
|
||||
// * __STL_USE_SGI_ALLOCATORS: if defined, then the STL will use older
|
||||
// SGI-style allocators, instead of standard-conforming allocators,
|
||||
// even if the compiler supports all of the language features needed
|
||||
// for standard-conforming allocators.
|
||||
// * __STL_NO_NAMESPACES: if defined, don't put the library in namespace
|
||||
// std, even if the compiler supports namespaces.
|
||||
// * __STL_ASSERTIONS: if defined, then enable runtime checking through the
|
||||
// __stl_assert macro.
|
||||
// * _PTHREADS: if defined, use Posix threads for multithreading support.
|
||||
// * _NOTHREADS: if defined, don't use any multithreading support.
|
||||
|
||||
|
||||
// Other macros defined by this file:
|
||||
|
||||
// * bool, true, and false, if __STL_NO_BOOL is defined.
|
||||
// * typename, as a null macro if it's not already a keyword.
|
||||
// * explicit, as a null macro if it's not already a keyword.
|
||||
// * namespace-related macros (__STD, __STL_BEGIN_NAMESPACE, etc.)
|
||||
// * exception-related macros (__STL_TRY, __STL_UNWIND, etc.)
|
||||
// * __stl_assert, either as a test or as a null macro, depending on
|
||||
// whether or not __STL_ASSERTIONS is defined.
|
||||
|
||||
#ifdef _PTHREADS
|
||||
# define __STL_PTHREADS
|
||||
#endif
|
||||
#ifdef _SOLTHREADS
|
||||
# define __STL_SOLTHREADS
|
||||
#endif
|
||||
|
||||
# if defined(__sgi) && !defined(__GNUC__)
|
||||
# if !defined(_BOOL)
|
||||
# define __STL_NEED_BOOL
|
||||
# define __STL_NO_BOOL
|
||||
# endif
|
||||
# if defined(_WCHAR_T_IS_KEYWORD)
|
||||
# define __STL_HAS_WCHAR_T
|
||||
# endif
|
||||
# if !defined(_TYPENAME_IS_KEYWORD)
|
||||
# define __STL_NEED_TYPENAME
|
||||
@ -87,6 +119,13 @@
|
||||
# endif
|
||||
# ifdef _MEMBER_TEMPLATES
|
||||
# define __STL_MEMBER_TEMPLATES
|
||||
# define __STL_MEMBER_TEMPLATE_CLASSES
|
||||
# endif
|
||||
# if defined(_MEMBER_TEMPLATE_KEYWORD)
|
||||
# define __STL_MEMBER_TEMPLATE_KEYWORD
|
||||
# endif
|
||||
# if (_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32
|
||||
# define __STL_MEMBER_TEMPLATE_KEYWORD
|
||||
# endif
|
||||
# if !defined(_EXPLICIT_IS_KEYWORD)
|
||||
# define __STL_NEED_EXPLICIT
|
||||
@ -95,15 +134,22 @@
|
||||
# define __STL_USE_EXCEPTIONS
|
||||
# endif
|
||||
# if (_COMPILER_VERSION >= 721) && defined(_NAMESPACES)
|
||||
# define __STL_USE_NAMESPACES
|
||||
# endif
|
||||
# define __STL_HAS_NAMESPACES
|
||||
# endif
|
||||
# if (_COMPILER_VERSION < 721)
|
||||
# define __STL_NO_EXCEPTION_HEADER
|
||||
# endif
|
||||
# if !defined(_NOTHREADS) && !defined(__STL_PTHREADS)
|
||||
# define __STL_SGI_THREADS
|
||||
# endif
|
||||
# if defined(_LONGLONG) && defined(_SGIAPI) && _SGIAPI
|
||||
# define __STL_LONG_LONG
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef __GNUC__
|
||||
# include <_G_config.h>
|
||||
# define __STL_HAS_WCHAR_T
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
|
||||
# define __STL_STATIC_TEMPLATE_MEMBER_BUG
|
||||
# define __STL_NEED_TYPENAME
|
||||
@ -111,21 +157,35 @@
|
||||
# else
|
||||
# define __STL_CLASS_PARTIAL_SPECIALIZATION
|
||||
# define __STL_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
# define __STL_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
# define __STL_MEMBER_TEMPLATES
|
||||
# define __STL_MEMBER_TEMPLATE_CLASSES
|
||||
# define __STL_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
# define __STL_HAS_NAMESPACES
|
||||
# define __STL_NO_NAMESPACES
|
||||
# define __SGI_STL_USE_AUTO_PTR_CONVERSIONS
|
||||
# define __STL_USE_NAMESPACES
|
||||
# endif
|
||||
/* glibc pre 2.0 is very buggy. We have to disable thread for it.
|
||||
It should be upgraded to glibc 2.0 or later. */
|
||||
# if !defined(_NOTHREADS) && __GLIBC__ >= 2 && defined(_G_USING_THUNKS)
|
||||
# define __STL_PTHREADS
|
||||
# if defined(__linux__)
|
||||
/* glibc pre 2.0 is very buggy. We have to disable thread for it.
|
||||
It should be upgraded to glibc 2.0 or later. */
|
||||
# if !defined(_NOTHREADS) && __GLIBC__ >= 2 && defined(_G_USING_THUNKS)
|
||||
# define __STL_PTHREADS
|
||||
# ifdef __STRICT_ANSI__
|
||||
/* Work around a bug in the glibc 2.0.x pthread.h. */
|
||||
# define sigset_t __sigset_t
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# ifdef __EXCEPTIONS
|
||||
# define __STL_USE_EXCEPTIONS
|
||||
# endif
|
||||
# ifndef __STRICT_ANSI__
|
||||
# define __STL_LONG_LONG
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if defined(__SUNPRO_CC)
|
||||
# define __STL_NEED_BOOL
|
||||
# if defined(__SUNPRO_CC)
|
||||
# define __STL_NO_BOOL
|
||||
# define __STL_NEED_TYPENAME
|
||||
# define __STL_NEED_EXPLICIT
|
||||
# define __STL_USE_EXCEPTIONS
|
||||
@ -133,21 +193,30 @@
|
||||
|
||||
# if defined(__COMO__)
|
||||
# define __STL_MEMBER_TEMPLATES
|
||||
# define __STL_MEMBER_TEMPLATE_CLASSES
|
||||
# define __STL_CLASS_PARTIAL_SPECIALIZATION
|
||||
# define __STL_USE_EXCEPTIONS
|
||||
# define __STL_USE_NAMESPACES
|
||||
# define __STL_HAS_NAMESPACES
|
||||
# endif
|
||||
|
||||
# if defined(__MINGW32__)
|
||||
# define __STL_NO_DRAND48
|
||||
# endif
|
||||
|
||||
# if defined(__CYGWIN__)
|
||||
# define __STL_NO_DRAND48
|
||||
# endif
|
||||
|
||||
# if defined(_MSC_VER)
|
||||
# if _MSC_VER > 1000
|
||||
# include <yvals.h>
|
||||
# else
|
||||
# define __STL_NEED_BOOL
|
||||
# endif
|
||||
# define __STL_NO_DRAND48
|
||||
# define __STL_NEED_TYPENAME
|
||||
# if _MSC_VER < 1100
|
||||
# if _MSC_VER < 1100 /* 1000 is version 4.0, 1100 is 5.0, 1200 is 6.0. */
|
||||
# define __STL_NEED_EXPLICIT
|
||||
# define __STL_NO_BOOL
|
||||
# if _MSC_VER > 1000
|
||||
# include <yvals.h>
|
||||
# define __STL_DONT_USE_BOOL_TYPEDEF
|
||||
# endif
|
||||
# endif
|
||||
# define __STL_NON_TYPE_TMPL_PARAM_BUG
|
||||
# define __SGI_STL_NO_ARROW_OPERATOR
|
||||
@ -157,6 +226,11 @@
|
||||
# ifdef _MT
|
||||
# define __STL_WIN32THREADS
|
||||
# endif
|
||||
# if _MSC_VER >= 1200
|
||||
# define __STL_PARTIAL_SPECIALIZATION_SYNTAX
|
||||
# define __STL_HAS_NAMESPACES
|
||||
# define __STL_NO_NAMESPACES
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if defined(__BORLANDC__)
|
||||
@ -173,8 +247,7 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
|
||||
# if defined(__STL_NEED_BOOL)
|
||||
# if defined(__STL_NO_BOOL) && !defined(__STL_DONT_USE_BOOL_TYPEDEF)
|
||||
typedef int bool;
|
||||
# define true 1
|
||||
# define false 0
|
||||
@ -184,6 +257,12 @@
|
||||
# define typename
|
||||
# endif
|
||||
|
||||
# ifdef __STL_MEMBER_TEMPLATE_KEYWORD
|
||||
# define __STL_TEMPLATE template
|
||||
# else
|
||||
# define __STL_TEMPLATE
|
||||
# endif
|
||||
|
||||
# ifdef __STL_NEED_EXPLICIT
|
||||
# define explicit
|
||||
# endif
|
||||
@ -194,44 +273,71 @@
|
||||
# define __STL_NULL_TMPL_ARGS
|
||||
# endif
|
||||
|
||||
# ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
|
||||
# if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) \
|
||||
|| defined (__STL_PARTIAL_SPECIALIZATION_SYNTAX)
|
||||
# define __STL_TEMPLATE_NULL template<>
|
||||
# else
|
||||
# define __STL_TEMPLATE_NULL
|
||||
# endif
|
||||
|
||||
// Use standard-conforming allocators if we have the necessary language
|
||||
// features. __STL_USE_SGI_ALLOCATORS is a hook so that users can
|
||||
// disable new-style allocators, and continue to use the same kind of
|
||||
// allocators as before, without having to edit library headers.
|
||||
# if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && \
|
||||
defined(__STL_MEMBER_TEMPLATES) && \
|
||||
defined(__STL_MEMBER_TEMPLATE_CLASSES) && \
|
||||
!defined(__STL_NO_BOOL) && \
|
||||
!defined(__STL_NON_TYPE_TMPL_PARAM_BUG) && \
|
||||
!defined(__STL_LIMITED_DEFAULT_TEMPLATES) && \
|
||||
!defined(__STL_USE_SGI_ALLOCATORS)
|
||||
# define __STL_USE_STD_ALLOCATORS
|
||||
# endif
|
||||
|
||||
# ifndef __STL_DEFAULT_ALLOCATOR
|
||||
# ifdef __STL_USE_STD_ALLOCATORS
|
||||
# define __STL_DEFAULT_ALLOCATOR(T) allocator<T>
|
||||
# else
|
||||
# define __STL_DEFAULT_ALLOCATOR(T) alloc
|
||||
# endif
|
||||
# endif
|
||||
|
||||
// __STL_NO_NAMESPACES is a hook so that users can disable namespaces
|
||||
// without having to edit library headers.
|
||||
# if defined(__STL_USE_NAMESPACES) && !defined(__STL_NO_NAMESPACES)
|
||||
# if defined(__STL_HAS_NAMESPACES) && !defined(__STL_NO_NAMESPACES)
|
||||
# define __STD std
|
||||
# define __STL_BEGIN_NAMESPACE namespace std {
|
||||
# define __STL_END_NAMESPACE }
|
||||
# define __STL_USE_NAMESPACE_FOR_RELOPS
|
||||
# define __STL_USE_NAMESPACE_FOR_RELOPS
|
||||
# define __STL_BEGIN_RELOPS_NAMESPACE namespace std {
|
||||
# define __STL_END_RELOPS_NAMESPACE }
|
||||
# define __STD_RELOPS std
|
||||
# define __STL_USE_NAMESPACES
|
||||
# else
|
||||
# define __STD
|
||||
# define __STL_BEGIN_NAMESPACE
|
||||
# define __STL_END_NAMESPACE
|
||||
# define __STD
|
||||
# define __STL_BEGIN_NAMESPACE
|
||||
# define __STL_END_NAMESPACE
|
||||
# undef __STL_USE_NAMESPACE_FOR_RELOPS
|
||||
# define __STL_BEGIN_RELOPS_NAMESPACE
|
||||
# define __STL_END_RELOPS_NAMESPACE
|
||||
# define __STD_RELOPS
|
||||
# define __STL_BEGIN_RELOPS_NAMESPACE
|
||||
# define __STL_END_RELOPS_NAMESPACE
|
||||
# define __STD_RELOPS
|
||||
# undef __STL_USE_NAMESPACES
|
||||
# endif
|
||||
|
||||
# ifdef __STL_USE_EXCEPTIONS
|
||||
# define __STL_TRY try
|
||||
# define __STL_CATCH_ALL catch(...)
|
||||
# define __STL_THROW(x) throw x
|
||||
# define __STL_RETHROW throw
|
||||
# define __STL_NOTHROW throw()
|
||||
# define __STL_UNWIND(action) catch(...) { action; throw; }
|
||||
# else
|
||||
# define __STL_TRY
|
||||
# define __STL_TRY
|
||||
# define __STL_CATCH_ALL if (false)
|
||||
# define __STL_RETHROW
|
||||
# define __STL_NOTHROW
|
||||
# define __STL_UNWIND(action)
|
||||
# define __STL_THROW(x)
|
||||
# define __STL_RETHROW
|
||||
# define __STL_NOTHROW
|
||||
# define __STL_UNWIND(action)
|
||||
# endif
|
||||
|
||||
#ifdef __STL_ASSERTIONS
|
||||
|
@ -35,35 +35,47 @@
|
||||
|
||||
__STL_BEGIN_NAMESPACE
|
||||
|
||||
template <class T>
|
||||
inline void destroy(T* pointer) {
|
||||
pointer->~T();
|
||||
// construct and destroy. These functions are not part of the C++ standard,
|
||||
// and are provided for backward compatibility with the HP STL.
|
||||
|
||||
template <class _Tp>
|
||||
inline void destroy(_Tp* __pointer) {
|
||||
__pointer->~_Tp();
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
inline void construct(T1* p, const T2& value) {
|
||||
new (p) T1(value);
|
||||
template <class _T1, class _T2>
|
||||
inline void construct(_T1* __p, const _T2& __value) {
|
||||
new (__p) _T1(__value);
|
||||
}
|
||||
|
||||
template <class ForwardIterator>
|
||||
template <class _T1>
|
||||
inline void construct(_T1* __p) {
|
||||
new (__p) _T1();
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
inline void
|
||||
__destroy_aux(ForwardIterator first, ForwardIterator last, __false_type) {
|
||||
for ( ; first < last; ++first)
|
||||
destroy(&*first);
|
||||
__destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type)
|
||||
{
|
||||
for ( ; __first != __last; ++__first)
|
||||
destroy(&*__first);
|
||||
}
|
||||
|
||||
template <class ForwardIterator>
|
||||
inline void __destroy_aux(ForwardIterator, ForwardIterator, __true_type) {}
|
||||
template <class _ForwardIterator>
|
||||
inline void __destroy_aux(_ForwardIterator, _ForwardIterator, __true_type) {}
|
||||
|
||||
template <class ForwardIterator, class T>
|
||||
inline void __destroy(ForwardIterator first, ForwardIterator last, T*) {
|
||||
typedef typename __type_traits<T>::has_trivial_destructor trivial_destructor;
|
||||
__destroy_aux(first, last, trivial_destructor());
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
inline void
|
||||
__destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*)
|
||||
{
|
||||
typedef typename __type_traits<_Tp>::has_trivial_destructor
|
||||
_Trivial_destructor;
|
||||
__destroy_aux(__first, __last, _Trivial_destructor());
|
||||
}
|
||||
|
||||
template <class ForwardIterator>
|
||||
inline void destroy(ForwardIterator first, ForwardIterator last) {
|
||||
__destroy(first, last, value_type(first));
|
||||
template <class _ForwardIterator>
|
||||
inline void destroy(_ForwardIterator __first, _ForwardIterator __last) {
|
||||
__destroy(__first, __last, __VALUE_TYPE(__first));
|
||||
}
|
||||
|
||||
inline void destroy(char*, char*) {}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996
|
||||
* Copyright (c) 1996-1998
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
@ -35,53 +35,53 @@
|
||||
|
||||
__STL_BEGIN_NAMESPACE
|
||||
|
||||
template <class Key> struct hash { };
|
||||
template <class _Key> struct hash { };
|
||||
|
||||
inline size_t __stl_hash_string(const char* s)
|
||||
inline size_t __stl_hash_string(const char* __s)
|
||||
{
|
||||
unsigned long h = 0;
|
||||
for ( ; *s; ++s)
|
||||
h = 5*h + *s;
|
||||
unsigned long __h = 0;
|
||||
for ( ; *__s; ++__s)
|
||||
__h = 5*__h + *__s;
|
||||
|
||||
return size_t(h);
|
||||
return size_t(__h);
|
||||
}
|
||||
|
||||
__STL_TEMPLATE_NULL struct hash<char*>
|
||||
{
|
||||
size_t operator()(const char* s) const { return __stl_hash_string(s); }
|
||||
size_t operator()(const char* __s) const { return __stl_hash_string(__s); }
|
||||
};
|
||||
|
||||
__STL_TEMPLATE_NULL struct hash<const char*>
|
||||
{
|
||||
size_t operator()(const char* s) const { return __stl_hash_string(s); }
|
||||
size_t operator()(const char* __s) const { return __stl_hash_string(__s); }
|
||||
};
|
||||
|
||||
__STL_TEMPLATE_NULL struct hash<char> {
|
||||
size_t operator()(char x) const { return x; }
|
||||
size_t operator()(char __x) const { return __x; }
|
||||
};
|
||||
__STL_TEMPLATE_NULL struct hash<unsigned char> {
|
||||
size_t operator()(unsigned char x) const { return x; }
|
||||
size_t operator()(unsigned char __x) const { return __x; }
|
||||
};
|
||||
__STL_TEMPLATE_NULL struct hash<signed char> {
|
||||
size_t operator()(unsigned char x) const { return x; }
|
||||
size_t operator()(unsigned char __x) const { return __x; }
|
||||
};
|
||||
__STL_TEMPLATE_NULL struct hash<short> {
|
||||
size_t operator()(short x) const { return x; }
|
||||
size_t operator()(short __x) const { return __x; }
|
||||
};
|
||||
__STL_TEMPLATE_NULL struct hash<unsigned short> {
|
||||
size_t operator()(unsigned short x) const { return x; }
|
||||
size_t operator()(unsigned short __x) const { return __x; }
|
||||
};
|
||||
__STL_TEMPLATE_NULL struct hash<int> {
|
||||
size_t operator()(int x) const { return x; }
|
||||
size_t operator()(int __x) const { return __x; }
|
||||
};
|
||||
__STL_TEMPLATE_NULL struct hash<unsigned int> {
|
||||
size_t operator()(unsigned int x) const { return x; }
|
||||
size_t operator()(unsigned int __x) const { return __x; }
|
||||
};
|
||||
__STL_TEMPLATE_NULL struct hash<long> {
|
||||
size_t operator()(long x) const { return x; }
|
||||
size_t operator()(long __x) const { return __x; }
|
||||
};
|
||||
__STL_TEMPLATE_NULL struct hash<unsigned long> {
|
||||
size_t operator()(unsigned long x) const { return x; }
|
||||
size_t operator()(unsigned long __x) const { return __x; }
|
||||
};
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
@ -36,317 +36,375 @@ __STL_BEGIN_NAMESPACE
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
||||
#pragma set woff 1174
|
||||
#pragma set woff 1375
|
||||
#endif
|
||||
|
||||
#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
|
||||
template <class Key, class T, class HashFcn = hash<Key>,
|
||||
class EqualKey = equal_to<Key>,
|
||||
class Alloc = alloc>
|
||||
template <class _Key, class _Tp, class _HashFcn = hash<_Key>,
|
||||
class _EqualKey = equal_to<_Key>,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
|
||||
#else
|
||||
template <class Key, class T, class HashFcn, class EqualKey,
|
||||
class Alloc = alloc>
|
||||
template <class _Key, class _Tp, class _HashFcn, class _EqualKey,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
|
||||
#endif
|
||||
class hash_map
|
||||
{
|
||||
private:
|
||||
typedef hashtable<pair<const Key, T>, Key, HashFcn,
|
||||
select1st<pair<const Key, T> >, EqualKey, Alloc> ht;
|
||||
ht rep;
|
||||
typedef hashtable<pair<const _Key,_Tp>,_Key,_HashFcn,
|
||||
_Select1st<pair<const _Key,_Tp> >,_EqualKey,_Alloc> _Ht;
|
||||
_Ht _M_ht;
|
||||
|
||||
public:
|
||||
typedef typename ht::key_type key_type;
|
||||
typedef T data_type;
|
||||
typedef T mapped_type;
|
||||
typedef typename ht::value_type value_type;
|
||||
typedef typename ht::hasher hasher;
|
||||
typedef typename ht::key_equal key_equal;
|
||||
typedef typename _Ht::key_type key_type;
|
||||
typedef _Tp data_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef typename _Ht::value_type value_type;
|
||||
typedef typename _Ht::hasher hasher;
|
||||
typedef typename _Ht::key_equal key_equal;
|
||||
|
||||
typedef typename _Ht::size_type size_type;
|
||||
typedef typename _Ht::difference_type difference_type;
|
||||
typedef typename _Ht::pointer pointer;
|
||||
typedef typename _Ht::const_pointer const_pointer;
|
||||
typedef typename _Ht::reference reference;
|
||||
typedef typename _Ht::const_reference const_reference;
|
||||
|
||||
typedef typename ht::size_type size_type;
|
||||
typedef typename ht::difference_type difference_type;
|
||||
typedef typename ht::pointer pointer;
|
||||
typedef typename ht::const_pointer const_pointer;
|
||||
typedef typename ht::reference reference;
|
||||
typedef typename ht::const_reference const_reference;
|
||||
typedef typename _Ht::iterator iterator;
|
||||
typedef typename _Ht::const_iterator const_iterator;
|
||||
|
||||
typedef typename ht::iterator iterator;
|
||||
typedef typename ht::const_iterator const_iterator;
|
||||
typedef typename _Ht::allocator_type allocator_type;
|
||||
|
||||
hasher hash_funct() const { return rep.hash_funct(); }
|
||||
key_equal key_eq() const { return rep.key_eq(); }
|
||||
hasher hash_funct() const { return _M_ht.hash_funct(); }
|
||||
key_equal key_eq() const { return _M_ht.key_eq(); }
|
||||
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
|
||||
|
||||
public:
|
||||
hash_map() : rep(100, hasher(), key_equal()) {}
|
||||
explicit hash_map(size_type n) : rep(n, hasher(), key_equal()) {}
|
||||
hash_map(size_type n, const hasher& hf) : rep(n, hf, key_equal()) {}
|
||||
hash_map(size_type n, const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) {}
|
||||
hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
|
||||
explicit hash_map(size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
|
||||
hash_map(size_type __n, const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
|
||||
hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a) {}
|
||||
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
hash_map(InputIterator f, InputIterator l)
|
||||
: rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }
|
||||
template <class InputIterator>
|
||||
hash_map(InputIterator f, InputIterator l, size_type n)
|
||||
: rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }
|
||||
template <class InputIterator>
|
||||
hash_map(InputIterator f, InputIterator l, size_type n,
|
||||
const hasher& hf)
|
||||
: rep(n, hf, key_equal()) { rep.insert_unique(f, l); }
|
||||
template <class InputIterator>
|
||||
hash_map(InputIterator f, InputIterator l, size_type n,
|
||||
const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) { rep.insert_unique(f, l); }
|
||||
template <class _InputIterator>
|
||||
hash_map(_InputIterator __f, _InputIterator __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
#else
|
||||
hash_map(const value_type* f, const value_type* l)
|
||||
: rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }
|
||||
hash_map(const value_type* f, const value_type* l, size_type n)
|
||||
: rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }
|
||||
hash_map(const value_type* f, const value_type* l, size_type n,
|
||||
const hasher& hf)
|
||||
: rep(n, hf, key_equal()) { rep.insert_unique(f, l); }
|
||||
hash_map(const value_type* f, const value_type* l, size_type n,
|
||||
const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) { rep.insert_unique(f, l); }
|
||||
hash_map(const value_type* __f, const value_type* __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_map(const value_type* __f, const value_type* __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_map(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_map(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
hash_map(const_iterator f, const_iterator l)
|
||||
: rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }
|
||||
hash_map(const_iterator f, const_iterator l, size_type n)
|
||||
: rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }
|
||||
hash_map(const_iterator f, const_iterator l, size_type n,
|
||||
const hasher& hf)
|
||||
: rep(n, hf, key_equal()) { rep.insert_unique(f, l); }
|
||||
hash_map(const_iterator f, const_iterator l, size_type n,
|
||||
const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) { rep.insert_unique(f, l); }
|
||||
hash_map(const_iterator __f, const_iterator __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_map(const_iterator __f, const_iterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_map(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_map(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
#endif /*__STL_MEMBER_TEMPLATES */
|
||||
|
||||
public:
|
||||
size_type size() const { return rep.size(); }
|
||||
size_type max_size() const { return rep.max_size(); }
|
||||
bool empty() const { return rep.empty(); }
|
||||
void swap(hash_map& hs) { rep.swap(hs.rep); }
|
||||
size_type size() const { return _M_ht.size(); }
|
||||
size_type max_size() const { return _M_ht.max_size(); }
|
||||
bool empty() const { return _M_ht.empty(); }
|
||||
void swap(hash_map& __hs) { _M_ht.swap(__hs._M_ht); }
|
||||
friend bool
|
||||
operator== __STL_NULL_TMPL_ARGS (const hash_map&, const hash_map&);
|
||||
|
||||
iterator begin() { return rep.begin(); }
|
||||
iterator end() { return rep.end(); }
|
||||
const_iterator begin() const { return rep.begin(); }
|
||||
const_iterator end() const { return rep.end(); }
|
||||
iterator begin() { return _M_ht.begin(); }
|
||||
iterator end() { return _M_ht.end(); }
|
||||
const_iterator begin() const { return _M_ht.begin(); }
|
||||
const_iterator end() const { return _M_ht.end(); }
|
||||
|
||||
public:
|
||||
pair<iterator, bool> insert(const value_type& obj)
|
||||
{ return rep.insert_unique(obj); }
|
||||
pair<iterator,bool> insert(const value_type& __obj)
|
||||
{ return _M_ht.insert_unique(__obj); }
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator f, InputIterator l) { rep.insert_unique(f,l); }
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __f, _InputIterator __l)
|
||||
{ _M_ht.insert_unique(__f,__l); }
|
||||
#else
|
||||
void insert(const value_type* f, const value_type* l) {
|
||||
rep.insert_unique(f,l);
|
||||
void insert(const value_type* __f, const value_type* __l) {
|
||||
_M_ht.insert_unique(__f,__l);
|
||||
}
|
||||
void insert(const_iterator f, const_iterator l) { rep.insert_unique(f, l); }
|
||||
void insert(const_iterator __f, const_iterator __l)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
#endif /*__STL_MEMBER_TEMPLATES */
|
||||
pair<iterator, bool> insert_noresize(const value_type& obj)
|
||||
{ return rep.insert_unique_noresize(obj); }
|
||||
pair<iterator,bool> insert_noresize(const value_type& __obj)
|
||||
{ return _M_ht.insert_unique_noresize(__obj); }
|
||||
|
||||
iterator find(const key_type& key) { return rep.find(key); }
|
||||
const_iterator find(const key_type& key) const { return rep.find(key); }
|
||||
iterator find(const key_type& __key) { return _M_ht.find(__key); }
|
||||
const_iterator find(const key_type& __key) const
|
||||
{ return _M_ht.find(__key); }
|
||||
|
||||
T& operator[](const key_type& key) {
|
||||
return rep.find_or_insert(value_type(key, T())).second;
|
||||
_Tp& operator[](const key_type& __key) {
|
||||
return _M_ht.find_or_insert(value_type(__key, _Tp())).second;
|
||||
}
|
||||
|
||||
size_type count(const key_type& key) const { return rep.count(key); }
|
||||
size_type count(const key_type& __key) const { return _M_ht.count(__key); }
|
||||
|
||||
pair<iterator, iterator> equal_range(const key_type& key)
|
||||
{ return rep.equal_range(key); }
|
||||
pair<const_iterator, const_iterator> equal_range(const key_type& key) const
|
||||
{ return rep.equal_range(key); }
|
||||
pair<iterator, iterator> equal_range(const key_type& __key)
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
pair<const_iterator, const_iterator>
|
||||
equal_range(const key_type& __key) const
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
|
||||
size_type erase(const key_type& key) {return rep.erase(key); }
|
||||
void erase(iterator it) { rep.erase(it); }
|
||||
void erase(iterator f, iterator l) { rep.erase(f, l); }
|
||||
void clear() { rep.clear(); }
|
||||
size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
|
||||
void erase(iterator __it) { _M_ht.erase(__it); }
|
||||
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
|
||||
void clear() { _M_ht.clear(); }
|
||||
|
||||
public:
|
||||
void resize(size_type hint) { rep.resize(hint); }
|
||||
size_type bucket_count() const { return rep.bucket_count(); }
|
||||
size_type max_bucket_count() const { return rep.max_bucket_count(); }
|
||||
size_type elems_in_bucket(size_type n) const
|
||||
{ return rep.elems_in_bucket(n); }
|
||||
void resize(size_type __hint) { _M_ht.resize(__hint); }
|
||||
size_type bucket_count() const { return _M_ht.bucket_count(); }
|
||||
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
|
||||
size_type elems_in_bucket(size_type __n) const
|
||||
{ return _M_ht.elems_in_bucket(__n); }
|
||||
};
|
||||
|
||||
template <class Key, class T, class HashFcn, class EqualKey, class Alloc>
|
||||
inline bool operator==(const hash_map<Key, T, HashFcn, EqualKey, Alloc>& hm1,
|
||||
const hash_map<Key, T, HashFcn, EqualKey, Alloc>& hm2)
|
||||
template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
|
||||
inline bool
|
||||
operator==(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
|
||||
const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
|
||||
{
|
||||
return hm1.rep == hm2.rep;
|
||||
return __hm1._M_ht == __hm2._M_ht;
|
||||
}
|
||||
|
||||
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
|
||||
template <class Key, class T, class HashFcn, class EqualKey, class Alloc>
|
||||
inline void swap(hash_map<Key, T, HashFcn, EqualKey, Alloc>& hm1,
|
||||
hash_map<Key, T, HashFcn, EqualKey, Alloc>& hm2)
|
||||
template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
|
||||
inline void
|
||||
swap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
|
||||
hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
|
||||
{
|
||||
hm1.swap(hm2);
|
||||
__hm1.swap(__hm2);
|
||||
}
|
||||
|
||||
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
|
||||
#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
|
||||
template <class Key, class T, class HashFcn = hash<Key>,
|
||||
class EqualKey = equal_to<Key>,
|
||||
class Alloc = alloc>
|
||||
template <class _Key, class _Tp, class _HashFcn = hash<_Key>,
|
||||
class _EqualKey = equal_to<_Key>,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
|
||||
#else
|
||||
template <class Key, class T, class HashFcn, class EqualKey,
|
||||
class Alloc = alloc>
|
||||
template <class _Key, class _Tp, class _HashFcn, class _EqualKey,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
|
||||
#endif
|
||||
class hash_multimap
|
||||
{
|
||||
private:
|
||||
typedef hashtable<pair<const Key, T>, Key, HashFcn,
|
||||
select1st<pair<const Key, T> >, EqualKey, Alloc> ht;
|
||||
ht rep;
|
||||
typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFcn,
|
||||
_Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc>
|
||||
_Ht;
|
||||
_Ht _M_ht;
|
||||
|
||||
public:
|
||||
typedef typename ht::key_type key_type;
|
||||
typedef T data_type;
|
||||
typedef T mapped_type;
|
||||
typedef typename ht::value_type value_type;
|
||||
typedef typename ht::hasher hasher;
|
||||
typedef typename ht::key_equal key_equal;
|
||||
typedef typename _Ht::key_type key_type;
|
||||
typedef _Tp data_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef typename _Ht::value_type value_type;
|
||||
typedef typename _Ht::hasher hasher;
|
||||
typedef typename _Ht::key_equal key_equal;
|
||||
|
||||
typedef typename ht::size_type size_type;
|
||||
typedef typename ht::difference_type difference_type;
|
||||
typedef typename ht::pointer pointer;
|
||||
typedef typename ht::const_pointer const_pointer;
|
||||
typedef typename ht::reference reference;
|
||||
typedef typename ht::const_reference const_reference;
|
||||
typedef typename _Ht::size_type size_type;
|
||||
typedef typename _Ht::difference_type difference_type;
|
||||
typedef typename _Ht::pointer pointer;
|
||||
typedef typename _Ht::const_pointer const_pointer;
|
||||
typedef typename _Ht::reference reference;
|
||||
typedef typename _Ht::const_reference const_reference;
|
||||
|
||||
typedef typename ht::iterator iterator;
|
||||
typedef typename ht::const_iterator const_iterator;
|
||||
typedef typename _Ht::iterator iterator;
|
||||
typedef typename _Ht::const_iterator const_iterator;
|
||||
|
||||
hasher hash_funct() const { return rep.hash_funct(); }
|
||||
key_equal key_eq() const { return rep.key_eq(); }
|
||||
typedef typename _Ht::allocator_type allocator_type;
|
||||
|
||||
hasher hash_funct() const { return _M_ht.hash_funct(); }
|
||||
key_equal key_eq() const { return _M_ht.key_eq(); }
|
||||
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
|
||||
|
||||
public:
|
||||
hash_multimap() : rep(100, hasher(), key_equal()) {}
|
||||
explicit hash_multimap(size_type n) : rep(n, hasher(), key_equal()) {}
|
||||
hash_multimap(size_type n, const hasher& hf) : rep(n, hf, key_equal()) {}
|
||||
hash_multimap(size_type n, const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) {}
|
||||
hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
|
||||
explicit hash_multimap(size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
|
||||
hash_multimap(size_type __n, const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
|
||||
hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a) {}
|
||||
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
hash_multimap(InputIterator f, InputIterator l)
|
||||
: rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }
|
||||
template <class InputIterator>
|
||||
hash_multimap(InputIterator f, InputIterator l, size_type n)
|
||||
: rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }
|
||||
template <class InputIterator>
|
||||
hash_multimap(InputIterator f, InputIterator l, size_type n,
|
||||
const hasher& hf)
|
||||
: rep(n, hf, key_equal()) { rep.insert_equal(f, l); }
|
||||
template <class InputIterator>
|
||||
hash_multimap(InputIterator f, InputIterator l, size_type n,
|
||||
const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) { rep.insert_equal(f, l); }
|
||||
template <class _InputIterator>
|
||||
hash_multimap(_InputIterator __f, _InputIterator __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
#else
|
||||
hash_multimap(const value_type* f, const value_type* l)
|
||||
: rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }
|
||||
hash_multimap(const value_type* f, const value_type* l, size_type n)
|
||||
: rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }
|
||||
hash_multimap(const value_type* f, const value_type* l, size_type n,
|
||||
const hasher& hf)
|
||||
: rep(n, hf, key_equal()) { rep.insert_equal(f, l); }
|
||||
hash_multimap(const value_type* f, const value_type* l, size_type n,
|
||||
const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) { rep.insert_equal(f, l); }
|
||||
hash_multimap(const value_type* __f, const value_type* __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multimap(const value_type* __f, const value_type* __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
hash_multimap(const_iterator f, const_iterator l)
|
||||
: rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }
|
||||
hash_multimap(const_iterator f, const_iterator l, size_type n)
|
||||
: rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }
|
||||
hash_multimap(const_iterator f, const_iterator l, size_type n,
|
||||
const hasher& hf)
|
||||
: rep(n, hf, key_equal()) { rep.insert_equal(f, l); }
|
||||
hash_multimap(const_iterator f, const_iterator l, size_type n,
|
||||
const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) { rep.insert_equal(f, l); }
|
||||
hash_multimap(const_iterator __f, const_iterator __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multimap(const_iterator __f, const_iterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
#endif /*__STL_MEMBER_TEMPLATES */
|
||||
|
||||
public:
|
||||
size_type size() const { return rep.size(); }
|
||||
size_type max_size() const { return rep.max_size(); }
|
||||
bool empty() const { return rep.empty(); }
|
||||
void swap(hash_multimap& hs) { rep.swap(hs.rep); }
|
||||
size_type size() const { return _M_ht.size(); }
|
||||
size_type max_size() const { return _M_ht.max_size(); }
|
||||
bool empty() const { return _M_ht.empty(); }
|
||||
void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); }
|
||||
friend bool
|
||||
operator== __STL_NULL_TMPL_ARGS (const hash_multimap&, const hash_multimap&);
|
||||
operator== __STL_NULL_TMPL_ARGS (const hash_multimap&,
|
||||
const hash_multimap&);
|
||||
|
||||
iterator begin() { return rep.begin(); }
|
||||
iterator end() { return rep.end(); }
|
||||
const_iterator begin() const { return rep.begin(); }
|
||||
const_iterator end() const { return rep.end(); }
|
||||
iterator begin() { return _M_ht.begin(); }
|
||||
iterator end() { return _M_ht.end(); }
|
||||
const_iterator begin() const { return _M_ht.begin(); }
|
||||
const_iterator end() const { return _M_ht.end(); }
|
||||
|
||||
public:
|
||||
iterator insert(const value_type& obj) { return rep.insert_equal(obj); }
|
||||
iterator insert(const value_type& __obj)
|
||||
{ return _M_ht.insert_equal(__obj); }
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator f, InputIterator l) { rep.insert_equal(f,l); }
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __f, _InputIterator __l)
|
||||
{ _M_ht.insert_equal(__f,__l); }
|
||||
#else
|
||||
void insert(const value_type* f, const value_type* l) {
|
||||
rep.insert_equal(f,l);
|
||||
void insert(const value_type* __f, const value_type* __l) {
|
||||
_M_ht.insert_equal(__f,__l);
|
||||
}
|
||||
void insert(const_iterator f, const_iterator l) { rep.insert_equal(f, l); }
|
||||
void insert(const_iterator __f, const_iterator __l)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
#endif /*__STL_MEMBER_TEMPLATES */
|
||||
iterator insert_noresize(const value_type& obj)
|
||||
{ return rep.insert_equal_noresize(obj); }
|
||||
iterator insert_noresize(const value_type& __obj)
|
||||
{ return _M_ht.insert_equal_noresize(__obj); }
|
||||
|
||||
iterator find(const key_type& key) { return rep.find(key); }
|
||||
const_iterator find(const key_type& key) const { return rep.find(key); }
|
||||
iterator find(const key_type& __key) { return _M_ht.find(__key); }
|
||||
const_iterator find(const key_type& __key) const
|
||||
{ return _M_ht.find(__key); }
|
||||
|
||||
size_type count(const key_type& key) const { return rep.count(key); }
|
||||
size_type count(const key_type& __key) const { return _M_ht.count(__key); }
|
||||
|
||||
pair<iterator, iterator> equal_range(const key_type& key)
|
||||
{ return rep.equal_range(key); }
|
||||
pair<const_iterator, const_iterator> equal_range(const key_type& key) const
|
||||
{ return rep.equal_range(key); }
|
||||
pair<iterator, iterator> equal_range(const key_type& __key)
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
pair<const_iterator, const_iterator>
|
||||
equal_range(const key_type& __key) const
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
|
||||
size_type erase(const key_type& key) {return rep.erase(key); }
|
||||
void erase(iterator it) { rep.erase(it); }
|
||||
void erase(iterator f, iterator l) { rep.erase(f, l); }
|
||||
void clear() { rep.clear(); }
|
||||
size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
|
||||
void erase(iterator __it) { _M_ht.erase(__it); }
|
||||
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
|
||||
void clear() { _M_ht.clear(); }
|
||||
|
||||
public:
|
||||
void resize(size_type hint) { rep.resize(hint); }
|
||||
size_type bucket_count() const { return rep.bucket_count(); }
|
||||
size_type max_bucket_count() const { return rep.max_bucket_count(); }
|
||||
size_type elems_in_bucket(size_type n) const
|
||||
{ return rep.elems_in_bucket(n); }
|
||||
void resize(size_type __hint) { _M_ht.resize(__hint); }
|
||||
size_type bucket_count() const { return _M_ht.bucket_count(); }
|
||||
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
|
||||
size_type elems_in_bucket(size_type __n) const
|
||||
{ return _M_ht.elems_in_bucket(__n); }
|
||||
};
|
||||
|
||||
template <class Key, class T, class HF, class EqKey, class Alloc>
|
||||
inline bool operator==(const hash_multimap<Key, T, HF, EqKey, Alloc>& hm1,
|
||||
const hash_multimap<Key, T, HF, EqKey, Alloc>& hm2)
|
||||
template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
|
||||
inline bool
|
||||
operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
|
||||
const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2)
|
||||
{
|
||||
return hm1.rep == hm2.rep;
|
||||
return __hm1._M_ht == __hm2._M_ht;
|
||||
}
|
||||
|
||||
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
|
||||
template <class Key, class T, class HashFcn, class EqualKey, class Alloc>
|
||||
inline void swap(hash_multimap<Key, T, HashFcn, EqualKey, Alloc>& hm1,
|
||||
hash_multimap<Key, T, HashFcn, EqualKey, Alloc>& hm2)
|
||||
template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
|
||||
inline void
|
||||
swap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
|
||||
hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
|
||||
{
|
||||
hm1.swap(hm2);
|
||||
__hm1.swap(__hm2);
|
||||
}
|
||||
|
||||
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
||||
#pragma reset woff 1174
|
||||
#pragma reset woff 1375
|
||||
#endif
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
@ -35,303 +35,361 @@ __STL_BEGIN_NAMESPACE
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
||||
#pragma set woff 1174
|
||||
#pragma set woff 1375
|
||||
#endif
|
||||
|
||||
#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
|
||||
template <class Value, class HashFcn = hash<Value>,
|
||||
class EqualKey = equal_to<Value>,
|
||||
class Alloc = alloc>
|
||||
template <class _Value, class _HashFcn = hash<_Value>,
|
||||
class _EqualKey = equal_to<_Value>,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Value) >
|
||||
#else
|
||||
template <class Value, class HashFcn, class EqualKey, class Alloc = alloc>
|
||||
template <class _Value, class _HashFcn, class _EqualKey,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Value) >
|
||||
#endif
|
||||
class hash_set
|
||||
{
|
||||
private:
|
||||
typedef hashtable<Value, Value, HashFcn, identity<Value>,
|
||||
EqualKey, Alloc> ht;
|
||||
ht rep;
|
||||
typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
|
||||
_EqualKey, _Alloc> _Ht;
|
||||
_Ht _M_ht;
|
||||
|
||||
public:
|
||||
typedef typename ht::key_type key_type;
|
||||
typedef typename ht::value_type value_type;
|
||||
typedef typename ht::hasher hasher;
|
||||
typedef typename ht::key_equal key_equal;
|
||||
typedef typename _Ht::key_type key_type;
|
||||
typedef typename _Ht::value_type value_type;
|
||||
typedef typename _Ht::hasher hasher;
|
||||
typedef typename _Ht::key_equal key_equal;
|
||||
|
||||
typedef typename ht::size_type size_type;
|
||||
typedef typename ht::difference_type difference_type;
|
||||
typedef typename ht::const_pointer pointer;
|
||||
typedef typename ht::const_pointer const_pointer;
|
||||
typedef typename ht::const_reference reference;
|
||||
typedef typename ht::const_reference const_reference;
|
||||
typedef typename _Ht::size_type size_type;
|
||||
typedef typename _Ht::difference_type difference_type;
|
||||
typedef typename _Ht::const_pointer pointer;
|
||||
typedef typename _Ht::const_pointer const_pointer;
|
||||
typedef typename _Ht::const_reference reference;
|
||||
typedef typename _Ht::const_reference const_reference;
|
||||
|
||||
typedef typename ht::const_iterator iterator;
|
||||
typedef typename ht::const_iterator const_iterator;
|
||||
typedef typename _Ht::const_iterator iterator;
|
||||
typedef typename _Ht::const_iterator const_iterator;
|
||||
|
||||
hasher hash_funct() const { return rep.hash_funct(); }
|
||||
key_equal key_eq() const { return rep.key_eq(); }
|
||||
typedef typename _Ht::allocator_type allocator_type;
|
||||
|
||||
hasher hash_funct() const { return _M_ht.hash_funct(); }
|
||||
key_equal key_eq() const { return _M_ht.key_eq(); }
|
||||
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
|
||||
|
||||
public:
|
||||
hash_set() : rep(100, hasher(), key_equal()) {}
|
||||
explicit hash_set(size_type n) : rep(n, hasher(), key_equal()) {}
|
||||
hash_set(size_type n, const hasher& hf) : rep(n, hf, key_equal()) {}
|
||||
hash_set(size_type n, const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) {}
|
||||
hash_set()
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type()) {}
|
||||
explicit hash_set(size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
|
||||
hash_set(size_type __n, const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
|
||||
hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a) {}
|
||||
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
hash_set(InputIterator f, InputIterator l)
|
||||
: rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }
|
||||
template <class InputIterator>
|
||||
hash_set(InputIterator f, InputIterator l, size_type n)
|
||||
: rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }
|
||||
template <class InputIterator>
|
||||
hash_set(InputIterator f, InputIterator l, size_type n,
|
||||
const hasher& hf)
|
||||
: rep(n, hf, key_equal()) { rep.insert_unique(f, l); }
|
||||
template <class InputIterator>
|
||||
hash_set(InputIterator f, InputIterator l, size_type n,
|
||||
const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) { rep.insert_unique(f, l); }
|
||||
template <class _InputIterator>
|
||||
hash_set(_InputIterator __f, _InputIterator __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_set(_InputIterator __f, _InputIterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
#else
|
||||
|
||||
hash_set(const value_type* f, const value_type* l)
|
||||
: rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }
|
||||
hash_set(const value_type* f, const value_type* l, size_type n)
|
||||
: rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }
|
||||
hash_set(const value_type* f, const value_type* l, size_type n,
|
||||
const hasher& hf)
|
||||
: rep(n, hf, key_equal()) { rep.insert_unique(f, l); }
|
||||
hash_set(const value_type* f, const value_type* l, size_type n,
|
||||
const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) { rep.insert_unique(f, l); }
|
||||
hash_set(const value_type* __f, const value_type* __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_set(const value_type* __f, const value_type* __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_set(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_set(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
hash_set(const_iterator f, const_iterator l)
|
||||
: rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }
|
||||
hash_set(const_iterator f, const_iterator l, size_type n)
|
||||
: rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }
|
||||
hash_set(const_iterator f, const_iterator l, size_type n,
|
||||
const hasher& hf)
|
||||
: rep(n, hf, key_equal()) { rep.insert_unique(f, l); }
|
||||
hash_set(const_iterator f, const_iterator l, size_type n,
|
||||
const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) { rep.insert_unique(f, l); }
|
||||
hash_set(const_iterator __f, const_iterator __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_set(const_iterator __f, const_iterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_set(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_set(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
#endif /*__STL_MEMBER_TEMPLATES */
|
||||
|
||||
public:
|
||||
size_type size() const { return rep.size(); }
|
||||
size_type max_size() const { return rep.max_size(); }
|
||||
bool empty() const { return rep.empty(); }
|
||||
void swap(hash_set& hs) { rep.swap(hs.rep); }
|
||||
size_type size() const { return _M_ht.size(); }
|
||||
size_type max_size() const { return _M_ht.max_size(); }
|
||||
bool empty() const { return _M_ht.empty(); }
|
||||
void swap(hash_set& __hs) { _M_ht.swap(__hs._M_ht); }
|
||||
friend bool operator== __STL_NULL_TMPL_ARGS (const hash_set&,
|
||||
const hash_set&);
|
||||
|
||||
iterator begin() const { return rep.begin(); }
|
||||
iterator end() const { return rep.end(); }
|
||||
iterator begin() const { return _M_ht.begin(); }
|
||||
iterator end() const { return _M_ht.end(); }
|
||||
|
||||
public:
|
||||
pair<iterator, bool> insert(const value_type& obj)
|
||||
pair<iterator, bool> insert(const value_type& __obj)
|
||||
{
|
||||
pair<typename ht::iterator, bool> p = rep.insert_unique(obj);
|
||||
return pair<iterator, bool>(p.first, p.second);
|
||||
pair<typename _Ht::iterator, bool> __p = _M_ht.insert_unique(__obj);
|
||||
return pair<iterator,bool>(__p.first, __p.second);
|
||||
}
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator f, InputIterator l) { rep.insert_unique(f,l); }
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __f, _InputIterator __l)
|
||||
{ _M_ht.insert_unique(__f,__l); }
|
||||
#else
|
||||
void insert(const value_type* f, const value_type* l) {
|
||||
rep.insert_unique(f,l);
|
||||
void insert(const value_type* __f, const value_type* __l) {
|
||||
_M_ht.insert_unique(__f,__l);
|
||||
}
|
||||
void insert(const_iterator f, const_iterator l) {rep.insert_unique(f, l); }
|
||||
void insert(const_iterator __f, const_iterator __l)
|
||||
{_M_ht.insert_unique(__f, __l); }
|
||||
#endif /*__STL_MEMBER_TEMPLATES */
|
||||
pair<iterator, bool> insert_noresize(const value_type& obj)
|
||||
pair<iterator, bool> insert_noresize(const value_type& __obj)
|
||||
{
|
||||
pair<typename ht::iterator, bool> p = rep.insert_unique_noresize(obj);
|
||||
return pair<iterator, bool>(p.first, p.second);
|
||||
pair<typename _Ht::iterator, bool> __p =
|
||||
_M_ht.insert_unique_noresize(__obj);
|
||||
return pair<iterator, bool>(__p.first, __p.second);
|
||||
}
|
||||
|
||||
iterator find(const key_type& key) const { return rep.find(key); }
|
||||
iterator find(const key_type& __key) const { return _M_ht.find(__key); }
|
||||
|
||||
size_type count(const key_type& key) const { return rep.count(key); }
|
||||
size_type count(const key_type& __key) const { return _M_ht.count(__key); }
|
||||
|
||||
pair<iterator, iterator> equal_range(const key_type& key) const
|
||||
{ return rep.equal_range(key); }
|
||||
pair<iterator, iterator> equal_range(const key_type& __key) const
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
|
||||
size_type erase(const key_type& key) {return rep.erase(key); }
|
||||
void erase(iterator it) { rep.erase(it); }
|
||||
void erase(iterator f, iterator l) { rep.erase(f, l); }
|
||||
void clear() { rep.clear(); }
|
||||
size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
|
||||
void erase(iterator __it) { _M_ht.erase(__it); }
|
||||
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
|
||||
void clear() { _M_ht.clear(); }
|
||||
|
||||
public:
|
||||
void resize(size_type hint) { rep.resize(hint); }
|
||||
size_type bucket_count() const { return rep.bucket_count(); }
|
||||
size_type max_bucket_count() const { return rep.max_bucket_count(); }
|
||||
size_type elems_in_bucket(size_type n) const
|
||||
{ return rep.elems_in_bucket(n); }
|
||||
void resize(size_type __hint) { _M_ht.resize(__hint); }
|
||||
size_type bucket_count() const { return _M_ht.bucket_count(); }
|
||||
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
|
||||
size_type elems_in_bucket(size_type __n) const
|
||||
{ return _M_ht.elems_in_bucket(__n); }
|
||||
};
|
||||
|
||||
template <class Value, class HashFcn, class EqualKey, class Alloc>
|
||||
inline bool operator==(const hash_set<Value, HashFcn, EqualKey, Alloc>& hs1,
|
||||
const hash_set<Value, HashFcn, EqualKey, Alloc>& hs2)
|
||||
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
inline bool
|
||||
operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1,
|
||||
const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2)
|
||||
{
|
||||
return hs1.rep == hs2.rep;
|
||||
return __hs1._M_ht == __hs2._M_ht;
|
||||
}
|
||||
|
||||
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
|
||||
template <class Val, class HashFcn, class EqualKey, class Alloc>
|
||||
inline void swap(hash_set<Val, HashFcn, EqualKey, Alloc>& hs1,
|
||||
hash_set<Val, HashFcn, EqualKey, Alloc>& hs2) {
|
||||
hs1.swap(hs2);
|
||||
template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
inline void
|
||||
swap(hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
|
||||
hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2)
|
||||
{
|
||||
__hs1.swap(__hs2);
|
||||
}
|
||||
|
||||
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
|
||||
|
||||
#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
|
||||
template <class Value, class HashFcn = hash<Value>,
|
||||
class EqualKey = equal_to<Value>,
|
||||
class Alloc = alloc>
|
||||
template <class _Value, class _HashFcn = hash<_Value>,
|
||||
class _EqualKey = equal_to<_Value>,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Value) >
|
||||
#else
|
||||
template <class Value, class HashFcn, class EqualKey, class Alloc = alloc>
|
||||
template <class _Value, class _HashFcn, class _EqualKey,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Value) >
|
||||
#endif
|
||||
class hash_multiset
|
||||
{
|
||||
private:
|
||||
typedef hashtable<Value, Value, HashFcn, identity<Value>,
|
||||
EqualKey, Alloc> ht;
|
||||
ht rep;
|
||||
typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
|
||||
_EqualKey, _Alloc> _Ht;
|
||||
_Ht _M_ht;
|
||||
|
||||
public:
|
||||
typedef typename ht::key_type key_type;
|
||||
typedef typename ht::value_type value_type;
|
||||
typedef typename ht::hasher hasher;
|
||||
typedef typename ht::key_equal key_equal;
|
||||
typedef typename _Ht::key_type key_type;
|
||||
typedef typename _Ht::value_type value_type;
|
||||
typedef typename _Ht::hasher hasher;
|
||||
typedef typename _Ht::key_equal key_equal;
|
||||
|
||||
typedef typename ht::size_type size_type;
|
||||
typedef typename ht::difference_type difference_type;
|
||||
typedef typename ht::const_pointer pointer;
|
||||
typedef typename ht::const_pointer const_pointer;
|
||||
typedef typename ht::const_reference reference;
|
||||
typedef typename ht::const_reference const_reference;
|
||||
typedef typename _Ht::size_type size_type;
|
||||
typedef typename _Ht::difference_type difference_type;
|
||||
typedef typename _Ht::const_pointer pointer;
|
||||
typedef typename _Ht::const_pointer const_pointer;
|
||||
typedef typename _Ht::const_reference reference;
|
||||
typedef typename _Ht::const_reference const_reference;
|
||||
|
||||
typedef typename ht::const_iterator iterator;
|
||||
typedef typename ht::const_iterator const_iterator;
|
||||
typedef typename _Ht::const_iterator iterator;
|
||||
typedef typename _Ht::const_iterator const_iterator;
|
||||
|
||||
hasher hash_funct() const { return rep.hash_funct(); }
|
||||
key_equal key_eq() const { return rep.key_eq(); }
|
||||
typedef typename _Ht::allocator_type allocator_type;
|
||||
|
||||
hasher hash_funct() const { return _M_ht.hash_funct(); }
|
||||
key_equal key_eq() const { return _M_ht.key_eq(); }
|
||||
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
|
||||
|
||||
public:
|
||||
hash_multiset() : rep(100, hasher(), key_equal()) {}
|
||||
explicit hash_multiset(size_type n) : rep(n, hasher(), key_equal()) {}
|
||||
hash_multiset(size_type n, const hasher& hf) : rep(n, hf, key_equal()) {}
|
||||
hash_multiset(size_type n, const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) {}
|
||||
hash_multiset()
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type()) {}
|
||||
explicit hash_multiset(size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
|
||||
hash_multiset(size_type __n, const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
|
||||
hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a) {}
|
||||
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
hash_multiset(InputIterator f, InputIterator l)
|
||||
: rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }
|
||||
template <class InputIterator>
|
||||
hash_multiset(InputIterator f, InputIterator l, size_type n)
|
||||
: rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }
|
||||
template <class InputIterator>
|
||||
hash_multiset(InputIterator f, InputIterator l, size_type n,
|
||||
const hasher& hf)
|
||||
: rep(n, hf, key_equal()) { rep.insert_equal(f, l); }
|
||||
template <class InputIterator>
|
||||
hash_multiset(InputIterator f, InputIterator l, size_type n,
|
||||
const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) { rep.insert_equal(f, l); }
|
||||
template <class _InputIterator>
|
||||
hash_multiset(_InputIterator __f, _InputIterator __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
#else
|
||||
|
||||
hash_multiset(const value_type* f, const value_type* l)
|
||||
: rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }
|
||||
hash_multiset(const value_type* f, const value_type* l, size_type n)
|
||||
: rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }
|
||||
hash_multiset(const value_type* f, const value_type* l, size_type n,
|
||||
const hasher& hf)
|
||||
: rep(n, hf, key_equal()) { rep.insert_equal(f, l); }
|
||||
hash_multiset(const value_type* f, const value_type* l, size_type n,
|
||||
const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) { rep.insert_equal(f, l); }
|
||||
hash_multiset(const value_type* __f, const value_type* __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multiset(const value_type* __f, const value_type* __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multiset(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multiset(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
hash_multiset(const_iterator f, const_iterator l)
|
||||
: rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }
|
||||
hash_multiset(const_iterator f, const_iterator l, size_type n)
|
||||
: rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }
|
||||
hash_multiset(const_iterator f, const_iterator l, size_type n,
|
||||
const hasher& hf)
|
||||
: rep(n, hf, key_equal()) { rep.insert_equal(f, l); }
|
||||
hash_multiset(const_iterator f, const_iterator l, size_type n,
|
||||
const hasher& hf, const key_equal& eql)
|
||||
: rep(n, hf, eql) { rep.insert_equal(f, l); }
|
||||
hash_multiset(const_iterator __f, const_iterator __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multiset(const_iterator __f, const_iterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multiset(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multiset(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
#endif /*__STL_MEMBER_TEMPLATES */
|
||||
|
||||
public:
|
||||
size_type size() const { return rep.size(); }
|
||||
size_type max_size() const { return rep.max_size(); }
|
||||
bool empty() const { return rep.empty(); }
|
||||
void swap(hash_multiset& hs) { rep.swap(hs.rep); }
|
||||
size_type size() const { return _M_ht.size(); }
|
||||
size_type max_size() const { return _M_ht.max_size(); }
|
||||
bool empty() const { return _M_ht.empty(); }
|
||||
void swap(hash_multiset& hs) { _M_ht.swap(hs._M_ht); }
|
||||
friend bool operator== __STL_NULL_TMPL_ARGS (const hash_multiset&,
|
||||
const hash_multiset&);
|
||||
|
||||
iterator begin() const { return rep.begin(); }
|
||||
iterator end() const { return rep.end(); }
|
||||
iterator begin() const { return _M_ht.begin(); }
|
||||
iterator end() const { return _M_ht.end(); }
|
||||
|
||||
public:
|
||||
iterator insert(const value_type& obj) { return rep.insert_equal(obj); }
|
||||
iterator insert(const value_type& __obj)
|
||||
{ return _M_ht.insert_equal(__obj); }
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator f, InputIterator l) { rep.insert_equal(f,l); }
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __f, _InputIterator __l)
|
||||
{ _M_ht.insert_equal(__f,__l); }
|
||||
#else
|
||||
void insert(const value_type* f, const value_type* l) {
|
||||
rep.insert_equal(f,l);
|
||||
void insert(const value_type* __f, const value_type* __l) {
|
||||
_M_ht.insert_equal(__f,__l);
|
||||
}
|
||||
void insert(const_iterator f, const_iterator l) { rep.insert_equal(f, l); }
|
||||
void insert(const_iterator __f, const_iterator __l)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
#endif /*__STL_MEMBER_TEMPLATES */
|
||||
iterator insert_noresize(const value_type& obj)
|
||||
{ return rep.insert_equal_noresize(obj); }
|
||||
iterator insert_noresize(const value_type& __obj)
|
||||
{ return _M_ht.insert_equal_noresize(__obj); }
|
||||
|
||||
iterator find(const key_type& key) const { return rep.find(key); }
|
||||
iterator find(const key_type& __key) const { return _M_ht.find(__key); }
|
||||
|
||||
size_type count(const key_type& key) const { return rep.count(key); }
|
||||
size_type count(const key_type& __key) const { return _M_ht.count(__key); }
|
||||
|
||||
pair<iterator, iterator> equal_range(const key_type& key) const
|
||||
{ return rep.equal_range(key); }
|
||||
pair<iterator, iterator> equal_range(const key_type& __key) const
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
|
||||
size_type erase(const key_type& key) {return rep.erase(key); }
|
||||
void erase(iterator it) { rep.erase(it); }
|
||||
void erase(iterator f, iterator l) { rep.erase(f, l); }
|
||||
void clear() { rep.clear(); }
|
||||
size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
|
||||
void erase(iterator __it) { _M_ht.erase(__it); }
|
||||
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
|
||||
void clear() { _M_ht.clear(); }
|
||||
|
||||
public:
|
||||
void resize(size_type hint) { rep.resize(hint); }
|
||||
size_type bucket_count() const { return rep.bucket_count(); }
|
||||
size_type max_bucket_count() const { return rep.max_bucket_count(); }
|
||||
size_type elems_in_bucket(size_type n) const
|
||||
{ return rep.elems_in_bucket(n); }
|
||||
void resize(size_type __hint) { _M_ht.resize(__hint); }
|
||||
size_type bucket_count() const { return _M_ht.bucket_count(); }
|
||||
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
|
||||
size_type elems_in_bucket(size_type __n) const
|
||||
{ return _M_ht.elems_in_bucket(__n); }
|
||||
};
|
||||
|
||||
template <class Val, class HashFcn, class EqualKey, class Alloc>
|
||||
inline bool operator==(const hash_multiset<Val, HashFcn, EqualKey, Alloc>& hs1,
|
||||
const hash_multiset<Val, HashFcn, EqualKey, Alloc>& hs2)
|
||||
template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
inline bool
|
||||
operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
|
||||
const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2)
|
||||
{
|
||||
return hs1.rep == hs2.rep;
|
||||
return __hs1._M_ht == __hs2._M_ht;
|
||||
}
|
||||
|
||||
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
|
||||
template <class Val, class HashFcn, class EqualKey, class Alloc>
|
||||
inline void swap(hash_multiset<Val, HashFcn, EqualKey, Alloc>& hs1,
|
||||
hash_multiset<Val, HashFcn, EqualKey, Alloc>& hs2)
|
||||
{
|
||||
hs1.swap(hs2);
|
||||
template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
inline void
|
||||
swap(hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
|
||||
hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) {
|
||||
__hs1.swap(__hs2);
|
||||
}
|
||||
|
||||
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
||||
#pragma reset woff 1174
|
||||
#pragma reset woff 1375
|
||||
#endif
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -36,181 +36,236 @@ __STL_BEGIN_NAMESPACE
|
||||
#pragma set woff 1209
|
||||
#endif
|
||||
|
||||
template <class RandomAccessIterator, class Distance, class T>
|
||||
void __push_heap(RandomAccessIterator first, Distance holeIndex,
|
||||
Distance topIndex, T value) {
|
||||
Distance parent = (holeIndex - 1) / 2;
|
||||
while (holeIndex > topIndex && *(first + parent) < value) {
|
||||
*(first + holeIndex) = *(first + parent);
|
||||
holeIndex = parent;
|
||||
parent = (holeIndex - 1) / 2;
|
||||
// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap.
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance, class _Tp>
|
||||
void
|
||||
__push_heap(_RandomAccessIterator __first,
|
||||
_Distance __holeIndex, _Distance __topIndex, _Tp __value)
|
||||
{
|
||||
_Distance __parent = (__holeIndex - 1) / 2;
|
||||
while (__holeIndex > __topIndex && *(__first + __parent) < __value) {
|
||||
*(__first + __holeIndex) = *(__first + __parent);
|
||||
__holeIndex = __parent;
|
||||
__parent = (__holeIndex - 1) / 2;
|
||||
}
|
||||
*(first + holeIndex) = value;
|
||||
*(__first + __holeIndex) = __value;
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class Distance, class T>
|
||||
inline void __push_heap_aux(RandomAccessIterator first,
|
||||
RandomAccessIterator last, Distance*, T*) {
|
||||
__push_heap(first, Distance((last - first) - 1), Distance(0),
|
||||
T(*(last - 1)));
|
||||
template <class _RandomAccessIterator, class _Distance, class _Tp>
|
||||
inline void
|
||||
__push_heap_aux(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Distance*, _Tp*)
|
||||
{
|
||||
__push_heap(__first, _Distance((__last - __first) - 1), _Distance(0),
|
||||
_Tp(*(__last - 1)));
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
inline void push_heap(RandomAccessIterator first, RandomAccessIterator last) {
|
||||
__push_heap_aux(first, last, distance_type(first), value_type(first));
|
||||
template <class _RandomAccessIterator>
|
||||
inline void
|
||||
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
__push_heap_aux(__first, __last,
|
||||
__DISTANCE_TYPE(__first), __VALUE_TYPE(__first));
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class Distance, class T, class Compare>
|
||||
void __push_heap(RandomAccessIterator first, Distance holeIndex,
|
||||
Distance topIndex, T value, Compare comp) {
|
||||
Distance parent = (holeIndex - 1) / 2;
|
||||
while (holeIndex > topIndex && comp(*(first + parent), value)) {
|
||||
*(first + holeIndex) = *(first + parent);
|
||||
holeIndex = parent;
|
||||
parent = (holeIndex - 1) / 2;
|
||||
template <class _RandomAccessIterator, class _Distance, class _Tp,
|
||||
class _Compare>
|
||||
void
|
||||
__push_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
_Distance __topIndex, _Tp __value, _Compare __comp)
|
||||
{
|
||||
_Distance __parent = (__holeIndex - 1) / 2;
|
||||
while (__holeIndex > __topIndex && __comp(*(__first + __parent), __value)) {
|
||||
*(__first + __holeIndex) = *(__first + __parent);
|
||||
__holeIndex = __parent;
|
||||
__parent = (__holeIndex - 1) / 2;
|
||||
}
|
||||
*(first + holeIndex) = value;
|
||||
*(__first + __holeIndex) = __value;
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class Compare, class Distance, class T>
|
||||
inline void __push_heap_aux(RandomAccessIterator first,
|
||||
RandomAccessIterator last, Compare comp,
|
||||
Distance*, T*) {
|
||||
__push_heap(first, Distance((last - first) - 1), Distance(0),
|
||||
T(*(last - 1)), comp);
|
||||
template <class _RandomAccessIterator, class _Compare,
|
||||
class _Distance, class _Tp>
|
||||
inline void
|
||||
__push_heap_aux(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Compare __comp,
|
||||
_Distance*, _Tp*)
|
||||
{
|
||||
__push_heap(__first, _Distance((__last - __first) - 1), _Distance(0),
|
||||
_Tp(*(__last - 1)), __comp);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class Compare>
|
||||
inline void push_heap(RandomAccessIterator first, RandomAccessIterator last,
|
||||
Compare comp) {
|
||||
__push_heap_aux(first, last, comp, distance_type(first), value_type(first));
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
inline void
|
||||
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_Compare __comp)
|
||||
{
|
||||
__push_heap_aux(__first, __last, __comp,
|
||||
__DISTANCE_TYPE(__first), __VALUE_TYPE(__first));
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class Distance, class T>
|
||||
void __adjust_heap(RandomAccessIterator first, Distance holeIndex,
|
||||
Distance len, T value) {
|
||||
Distance topIndex = holeIndex;
|
||||
Distance secondChild = 2 * holeIndex + 2;
|
||||
while (secondChild < len) {
|
||||
if (*(first + secondChild) < *(first + (secondChild - 1)))
|
||||
secondChild--;
|
||||
*(first + holeIndex) = *(first + secondChild);
|
||||
holeIndex = secondChild;
|
||||
secondChild = 2 * (secondChild + 1);
|
||||
template <class _RandomAccessIterator, class _Distance, class _Tp>
|
||||
void
|
||||
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
_Distance __len, _Tp __value)
|
||||
{
|
||||
_Distance __topIndex = __holeIndex;
|
||||
_Distance __secondChild = 2 * __holeIndex + 2;
|
||||
while (__secondChild < __len) {
|
||||
if (*(__first + __secondChild) < *(__first + (__secondChild - 1)))
|
||||
__secondChild--;
|
||||
*(__first + __holeIndex) = *(__first + __secondChild);
|
||||
__holeIndex = __secondChild;
|
||||
__secondChild = 2 * (__secondChild + 1);
|
||||
}
|
||||
if (secondChild == len) {
|
||||
*(first + holeIndex) = *(first + (secondChild - 1));
|
||||
holeIndex = secondChild - 1;
|
||||
if (__secondChild == __len) {
|
||||
*(__first + __holeIndex) = *(__first + (__secondChild - 1));
|
||||
__holeIndex = __secondChild - 1;
|
||||
}
|
||||
__push_heap(first, holeIndex, topIndex, value);
|
||||
__push_heap(__first, __holeIndex, __topIndex, __value);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class T, class Distance>
|
||||
inline void __pop_heap(RandomAccessIterator first, RandomAccessIterator last,
|
||||
RandomAccessIterator result, T value, Distance*) {
|
||||
*result = *first;
|
||||
__adjust_heap(first, Distance(0), Distance(last - first), value);
|
||||
template <class _RandomAccessIterator, class _Tp, class _Distance>
|
||||
inline void
|
||||
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_RandomAccessIterator __result, _Tp __value, _Distance*)
|
||||
{
|
||||
*__result = *__first;
|
||||
__adjust_heap(__first, _Distance(0), _Distance(__last - __first), __value);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class T>
|
||||
inline void __pop_heap_aux(RandomAccessIterator first,
|
||||
RandomAccessIterator last, T*) {
|
||||
__pop_heap(first, last - 1, last - 1, T(*(last - 1)), distance_type(first));
|
||||
template <class _RandomAccessIterator, class _Tp>
|
||||
inline void
|
||||
__pop_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_Tp*)
|
||||
{
|
||||
__pop_heap(__first, __last - 1, __last - 1,
|
||||
_Tp(*(__last - 1)), __DISTANCE_TYPE(__first));
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
inline void pop_heap(RandomAccessIterator first, RandomAccessIterator last) {
|
||||
__pop_heap_aux(first, last, value_type(first));
|
||||
template <class _RandomAccessIterator>
|
||||
inline void pop_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last)
|
||||
{
|
||||
__pop_heap_aux(__first, __last, __VALUE_TYPE(__first));
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class Distance, class T, class Compare>
|
||||
void __adjust_heap(RandomAccessIterator first, Distance holeIndex,
|
||||
Distance len, T value, Compare comp) {
|
||||
Distance topIndex = holeIndex;
|
||||
Distance secondChild = 2 * holeIndex + 2;
|
||||
while (secondChild < len) {
|
||||
if (comp(*(first + secondChild), *(first + (secondChild - 1))))
|
||||
secondChild--;
|
||||
*(first + holeIndex) = *(first + secondChild);
|
||||
holeIndex = secondChild;
|
||||
secondChild = 2 * (secondChild + 1);
|
||||
template <class _RandomAccessIterator, class _Distance,
|
||||
class _Tp, class _Compare>
|
||||
void
|
||||
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
_Distance __len, _Tp __value, _Compare __comp)
|
||||
{
|
||||
_Distance __topIndex = __holeIndex;
|
||||
_Distance __secondChild = 2 * __holeIndex + 2;
|
||||
while (__secondChild < __len) {
|
||||
if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1))))
|
||||
__secondChild--;
|
||||
*(__first + __holeIndex) = *(__first + __secondChild);
|
||||
__holeIndex = __secondChild;
|
||||
__secondChild = 2 * (__secondChild + 1);
|
||||
}
|
||||
if (secondChild == len) {
|
||||
*(first + holeIndex) = *(first + (secondChild - 1));
|
||||
holeIndex = secondChild - 1;
|
||||
if (__secondChild == __len) {
|
||||
*(__first + __holeIndex) = *(__first + (__secondChild - 1));
|
||||
__holeIndex = __secondChild - 1;
|
||||
}
|
||||
__push_heap(first, holeIndex, topIndex, value, comp);
|
||||
__push_heap(__first, __holeIndex, __topIndex, __value, __comp);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class T, class Compare, class Distance>
|
||||
inline void __pop_heap(RandomAccessIterator first, RandomAccessIterator last,
|
||||
RandomAccessIterator result, T value, Compare comp,
|
||||
Distance*) {
|
||||
*result = *first;
|
||||
__adjust_heap(first, Distance(0), Distance(last - first), value, comp);
|
||||
template <class _RandomAccessIterator, class _Tp, class _Compare,
|
||||
class _Distance>
|
||||
inline void
|
||||
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_RandomAccessIterator __result, _Tp __value, _Compare __comp,
|
||||
_Distance*)
|
||||
{
|
||||
*__result = *__first;
|
||||
__adjust_heap(__first, _Distance(0), _Distance(__last - __first),
|
||||
__value, __comp);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class T, class Compare>
|
||||
inline void __pop_heap_aux(RandomAccessIterator first,
|
||||
RandomAccessIterator last, T*, Compare comp) {
|
||||
__pop_heap(first, last - 1, last - 1, T(*(last - 1)), comp,
|
||||
distance_type(first));
|
||||
template <class _RandomAccessIterator, class _Tp, class _Compare>
|
||||
inline void
|
||||
__pop_heap_aux(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Tp*, _Compare __comp)
|
||||
{
|
||||
__pop_heap(__first, __last - 1, __last - 1, _Tp(*(__last - 1)), __comp,
|
||||
__DISTANCE_TYPE(__first));
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class Compare>
|
||||
inline void pop_heap(RandomAccessIterator first, RandomAccessIterator last,
|
||||
Compare comp) {
|
||||
__pop_heap_aux(first, last, value_type(first), comp);
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
inline void
|
||||
pop_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
__pop_heap_aux(__first, __last, __VALUE_TYPE(__first), __comp);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class T, class Distance>
|
||||
void __make_heap(RandomAccessIterator first, RandomAccessIterator last, T*,
|
||||
Distance*) {
|
||||
if (last - first < 2) return;
|
||||
Distance len = last - first;
|
||||
Distance parent = (len - 2)/2;
|
||||
template <class _RandomAccessIterator, class _Tp, class _Distance>
|
||||
void
|
||||
__make_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Tp*, _Distance*)
|
||||
{
|
||||
if (__last - __first < 2) return;
|
||||
_Distance __len = __last - __first;
|
||||
_Distance __parent = (__len - 2)/2;
|
||||
|
||||
while (true) {
|
||||
__adjust_heap(first, parent, len, T(*(first + parent)));
|
||||
if (parent == 0) return;
|
||||
parent--;
|
||||
__adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)));
|
||||
if (__parent == 0) return;
|
||||
__parent--;
|
||||
}
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
inline void make_heap(RandomAccessIterator first, RandomAccessIterator last) {
|
||||
__make_heap(first, last, value_type(first), distance_type(first));
|
||||
template <class _RandomAccessIterator>
|
||||
inline void
|
||||
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
__make_heap(__first, __last,
|
||||
__VALUE_TYPE(__first), __DISTANCE_TYPE(__first));
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class Compare, class T, class Distance>
|
||||
void __make_heap(RandomAccessIterator first, RandomAccessIterator last,
|
||||
Compare comp, T*, Distance*) {
|
||||
if (last - first < 2) return;
|
||||
Distance len = last - first;
|
||||
Distance parent = (len - 2)/2;
|
||||
template <class _RandomAccessIterator, class _Compare,
|
||||
class _Tp, class _Distance>
|
||||
void
|
||||
__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_Compare __comp, _Tp*, _Distance*)
|
||||
{
|
||||
if (__last - __first < 2) return;
|
||||
_Distance __len = __last - __first;
|
||||
_Distance __parent = (__len - 2)/2;
|
||||
|
||||
while (true) {
|
||||
__adjust_heap(first, parent, len, T(*(first + parent)), comp);
|
||||
if (parent == 0) return;
|
||||
parent--;
|
||||
__adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)),
|
||||
__comp);
|
||||
if (__parent == 0) return;
|
||||
__parent--;
|
||||
}
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class Compare>
|
||||
inline void make_heap(RandomAccessIterator first, RandomAccessIterator last,
|
||||
Compare comp) {
|
||||
__make_heap(first, last, comp, value_type(first), distance_type(first));
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
inline void
|
||||
make_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
__make_heap(__first, __last, __comp,
|
||||
__VALUE_TYPE(__first), __DISTANCE_TYPE(__first));
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void sort_heap(RandomAccessIterator first, RandomAccessIterator last) {
|
||||
while (last - first > 1) pop_heap(first, last--);
|
||||
template <class _RandomAccessIterator>
|
||||
void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
while (__last - __first > 1)
|
||||
pop_heap(__first, __last--);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class Compare>
|
||||
void sort_heap(RandomAccessIterator first, RandomAccessIterator last,
|
||||
Compare comp) {
|
||||
while (last - first > 1) pop_heap(first, last--, comp);
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
void
|
||||
sort_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
while (__last - __first > 1)
|
||||
pop_heap(__first, __last--, __comp);
|
||||
}
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -35,177 +35,202 @@ __STL_BEGIN_NAMESPACE
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
||||
#pragma set woff 1174
|
||||
#pragma set woff 1375
|
||||
#endif
|
||||
|
||||
#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
|
||||
template <class Key, class T, class Compare = less<Key>, class Alloc = alloc>
|
||||
template <class _Key, class _Tp, class _Compare = less<_Key>,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
|
||||
#else
|
||||
template <class Key, class T, class Compare, class Alloc = alloc>
|
||||
template <class _Key, class _Tp, class _Compare,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
|
||||
#endif
|
||||
class map {
|
||||
public:
|
||||
|
||||
// typedefs:
|
||||
|
||||
typedef Key key_type;
|
||||
typedef T data_type;
|
||||
typedef T mapped_type;
|
||||
typedef pair<const Key, T> value_type;
|
||||
typedef Compare key_compare;
|
||||
typedef _Key key_type;
|
||||
typedef _Tp data_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<const _Key, _Tp> value_type;
|
||||
typedef _Compare key_compare;
|
||||
|
||||
class value_compare
|
||||
: public binary_function<value_type, value_type, bool> {
|
||||
friend class map<Key, T, Compare, Alloc>;
|
||||
friend class map<_Key,_Tp,_Compare,_Alloc>;
|
||||
protected :
|
||||
Compare comp;
|
||||
value_compare(Compare c) : comp(c) {}
|
||||
_Compare _M_comp;
|
||||
value_compare(_Compare __c) : _M_comp(__c) {}
|
||||
public:
|
||||
bool operator()(const value_type& x, const value_type& y) const {
|
||||
return comp(x.first, y.first);
|
||||
bool operator()(const value_type& __x, const value_type& __y) const {
|
||||
return _M_comp(__x.first, __y.first);
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
typedef rb_tree<key_type, value_type,
|
||||
select1st<value_type>, key_compare, Alloc> rep_type;
|
||||
rep_type t; // red-black tree representing map
|
||||
typedef _Rb_tree<key_type, value_type,
|
||||
_Select1st<value_type>, key_compare, _Alloc> _Rep_type;
|
||||
_Rep_type _M_t; // red-black tree representing map
|
||||
public:
|
||||
typedef typename rep_type::pointer pointer;
|
||||
typedef typename rep_type::const_pointer const_pointer;
|
||||
typedef typename rep_type::reference reference;
|
||||
typedef typename rep_type::const_reference const_reference;
|
||||
typedef typename rep_type::iterator iterator;
|
||||
typedef typename rep_type::const_iterator const_iterator;
|
||||
typedef typename rep_type::reverse_iterator reverse_iterator;
|
||||
typedef typename rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename rep_type::size_type size_type;
|
||||
typedef typename rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::pointer pointer;
|
||||
typedef typename _Rep_type::const_pointer const_pointer;
|
||||
typedef typename _Rep_type::reference reference;
|
||||
typedef typename _Rep_type::const_reference const_reference;
|
||||
typedef typename _Rep_type::iterator iterator;
|
||||
typedef typename _Rep_type::const_iterator const_iterator;
|
||||
typedef typename _Rep_type::reverse_iterator reverse_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename _Rep_type::size_type size_type;
|
||||
typedef typename _Rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::allocator_type allocator_type;
|
||||
|
||||
// allocation/deallocation
|
||||
|
||||
map() : t(Compare()) {}
|
||||
explicit map(const Compare& comp) : t(comp) {}
|
||||
map() : _M_t(_Compare(), allocator_type()) {}
|
||||
explicit map(const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) {}
|
||||
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
map(InputIterator first, InputIterator last)
|
||||
: t(Compare()) { t.insert_unique(first, last); }
|
||||
template <class _InputIterator>
|
||||
map(_InputIterator __first, _InputIterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
template <class InputIterator>
|
||||
map(InputIterator first, InputIterator last, const Compare& comp)
|
||||
: t(comp) { t.insert_unique(first, last); }
|
||||
template <class _InputIterator>
|
||||
map(_InputIterator __first, _InputIterator __last, const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
||||
#else
|
||||
map(const value_type* first, const value_type* last)
|
||||
: t(Compare()) { t.insert_unique(first, last); }
|
||||
map(const value_type* first, const value_type* last, const Compare& comp)
|
||||
: t(comp) { t.insert_unique(first, last); }
|
||||
map(const value_type* __first, const value_type* __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
map(const value_type* __first,
|
||||
const value_type* __last, const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
||||
|
||||
map(const_iterator __first, const_iterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
map(const_iterator __first, const_iterator __last, const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
||||
|
||||
map(const_iterator first, const_iterator last)
|
||||
: t(Compare()) { t.insert_unique(first, last); }
|
||||
map(const_iterator first, const_iterator last, const Compare& comp)
|
||||
: t(comp) { t.insert_unique(first, last); }
|
||||
#endif /* __STL_MEMBER_TEMPLATES */
|
||||
|
||||
map(const map<Key, T, Compare, Alloc>& x) : t(x.t) {}
|
||||
map<Key, T, Compare, Alloc>& operator=(const map<Key, T, Compare, Alloc>& x)
|
||||
map(const map<_Key,_Tp,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {}
|
||||
map<_Key,_Tp,_Compare,_Alloc>&
|
||||
operator=(const map<_Key, _Tp, _Compare, _Alloc>& __x)
|
||||
{
|
||||
t = x.t;
|
||||
_M_t = __x._M_t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// accessors:
|
||||
|
||||
key_compare key_comp() const { return t.key_comp(); }
|
||||
value_compare value_comp() const { return value_compare(t.key_comp()); }
|
||||
iterator begin() { return t.begin(); }
|
||||
const_iterator begin() const { return t.begin(); }
|
||||
iterator end() { return t.end(); }
|
||||
const_iterator end() const { return t.end(); }
|
||||
reverse_iterator rbegin() { return t.rbegin(); }
|
||||
const_reverse_iterator rbegin() const { return t.rbegin(); }
|
||||
reverse_iterator rend() { return t.rend(); }
|
||||
const_reverse_iterator rend() const { return t.rend(); }
|
||||
bool empty() const { return t.empty(); }
|
||||
size_type size() const { return t.size(); }
|
||||
size_type max_size() const { return t.max_size(); }
|
||||
T& operator[](const key_type& k) {
|
||||
return (*((insert(value_type(k, T()))).first)).second;
|
||||
key_compare key_comp() const { return _M_t.key_comp(); }
|
||||
value_compare value_comp() const { return value_compare(_M_t.key_comp()); }
|
||||
allocator_type get_allocator() const { return _M_t.get_allocator(); }
|
||||
|
||||
iterator begin() { return _M_t.begin(); }
|
||||
const_iterator begin() const { return _M_t.begin(); }
|
||||
iterator end() { return _M_t.end(); }
|
||||
const_iterator end() const { return _M_t.end(); }
|
||||
reverse_iterator rbegin() { return _M_t.rbegin(); }
|
||||
const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
|
||||
reverse_iterator rend() { return _M_t.rend(); }
|
||||
const_reverse_iterator rend() const { return _M_t.rend(); }
|
||||
bool empty() const { return _M_t.empty(); }
|
||||
size_type size() const { return _M_t.size(); }
|
||||
size_type max_size() const { return _M_t.max_size(); }
|
||||
_Tp& operator[](const key_type& __k) {
|
||||
iterator __i = lower_bound(__k);
|
||||
// __i->first is greater than or equivalent to __k.
|
||||
if (__i == end() || key_comp()(__k, (*__i).first))
|
||||
__i = insert(__i, value_type(__k, _Tp()));
|
||||
return (*__i).second;
|
||||
}
|
||||
void swap(map<Key, T, Compare, Alloc>& x) { t.swap(x.t); }
|
||||
void swap(map<_Key,_Tp,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }
|
||||
|
||||
// insert/erase
|
||||
|
||||
pair<iterator,bool> insert(const value_type& x) { return t.insert_unique(x); }
|
||||
iterator insert(iterator position, const value_type& x) {
|
||||
return t.insert_unique(position, x);
|
||||
}
|
||||
pair<iterator,bool> insert(const value_type& __x)
|
||||
{ return _M_t.insert_unique(__x); }
|
||||
iterator insert(iterator position, const value_type& __x)
|
||||
{ return _M_t.insert_unique(position, __x); }
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last) {
|
||||
t.insert_unique(first, last);
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __first, _InputIterator __last) {
|
||||
_M_t.insert_unique(__first, __last);
|
||||
}
|
||||
#else
|
||||
void insert(const value_type* first, const value_type* last) {
|
||||
t.insert_unique(first, last);
|
||||
void insert(const value_type* __first, const value_type* __last) {
|
||||
_M_t.insert_unique(__first, __last);
|
||||
}
|
||||
void insert(const_iterator first, const_iterator last) {
|
||||
t.insert_unique(first, last);
|
||||
void insert(const_iterator __first, const_iterator __last) {
|
||||
_M_t.insert_unique(__first, __last);
|
||||
}
|
||||
#endif /* __STL_MEMBER_TEMPLATES */
|
||||
|
||||
void erase(iterator position) { t.erase(position); }
|
||||
size_type erase(const key_type& x) { return t.erase(x); }
|
||||
void erase(iterator first, iterator last) { t.erase(first, last); }
|
||||
void clear() { t.clear(); }
|
||||
void erase(iterator __position) { _M_t.erase(__position); }
|
||||
size_type erase(const key_type& __x) { return _M_t.erase(__x); }
|
||||
void erase(iterator __first, iterator __last)
|
||||
{ _M_t.erase(__first, __last); }
|
||||
void clear() { _M_t.clear(); }
|
||||
|
||||
// map operations:
|
||||
|
||||
iterator find(const key_type& x) { return t.find(x); }
|
||||
const_iterator find(const key_type& x) const { return t.find(x); }
|
||||
size_type count(const key_type& x) const { return t.count(x); }
|
||||
iterator lower_bound(const key_type& x) {return t.lower_bound(x); }
|
||||
const_iterator lower_bound(const key_type& x) const {
|
||||
return t.lower_bound(x);
|
||||
iterator find(const key_type& __x) { return _M_t.find(__x); }
|
||||
const_iterator find(const key_type& __x) const { return _M_t.find(__x); }
|
||||
size_type count(const key_type& __x) const { return _M_t.count(__x); }
|
||||
iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); }
|
||||
const_iterator lower_bound(const key_type& __x) const {
|
||||
return _M_t.lower_bound(__x);
|
||||
}
|
||||
iterator upper_bound(const key_type& x) {return t.upper_bound(x); }
|
||||
const_iterator upper_bound(const key_type& x) const {
|
||||
return t.upper_bound(x);
|
||||
iterator upper_bound(const key_type& __x) {return _M_t.upper_bound(__x); }
|
||||
const_iterator upper_bound(const key_type& __x) const {
|
||||
return _M_t.upper_bound(__x);
|
||||
}
|
||||
|
||||
pair<iterator,iterator> equal_range(const key_type& x) {
|
||||
return t.equal_range(x);
|
||||
pair<iterator,iterator> equal_range(const key_type& __x) {
|
||||
return _M_t.equal_range(__x);
|
||||
}
|
||||
pair<const_iterator,const_iterator> equal_range(const key_type& x) const {
|
||||
return t.equal_range(x);
|
||||
pair<const_iterator,const_iterator> equal_range(const key_type& __x) const {
|
||||
return _M_t.equal_range(__x);
|
||||
}
|
||||
friend bool operator== __STL_NULL_TMPL_ARGS (const map&, const map&);
|
||||
friend bool operator< __STL_NULL_TMPL_ARGS (const map&, const map&);
|
||||
};
|
||||
|
||||
template <class Key, class T, class Compare, class Alloc>
|
||||
inline bool operator==(const map<Key, T, Compare, Alloc>& x,
|
||||
const map<Key, T, Compare, Alloc>& y) {
|
||||
return x.t == y.t;
|
||||
template <class _Key, class _Tp, class _Compare, class _Alloc>
|
||||
inline bool operator==(const map<_Key,_Tp,_Compare,_Alloc>& __x,
|
||||
const map<_Key,_Tp,_Compare,_Alloc>& __y) {
|
||||
return __x._M_t == __y._M_t;
|
||||
}
|
||||
|
||||
template <class Key, class T, class Compare, class Alloc>
|
||||
inline bool operator<(const map<Key, T, Compare, Alloc>& x,
|
||||
const map<Key, T, Compare, Alloc>& y) {
|
||||
return x.t < y.t;
|
||||
template <class _Key, class _Tp, class _Compare, class _Alloc>
|
||||
inline bool operator<(const map<_Key,_Tp,_Compare,_Alloc>& __x,
|
||||
const map<_Key,_Tp,_Compare,_Alloc>& __y) {
|
||||
return __x._M_t < __y._M_t;
|
||||
}
|
||||
|
||||
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
|
||||
template <class Key, class T, class Compare, class Alloc>
|
||||
inline void swap(map<Key, T, Compare, Alloc>& x,
|
||||
map<Key, T, Compare, Alloc>& y) {
|
||||
x.swap(y);
|
||||
template <class _Key, class _Tp, class _Compare, class _Alloc>
|
||||
inline void swap(map<_Key,_Tp,_Compare,_Alloc>& __x,
|
||||
map<_Key,_Tp,_Compare,_Alloc>& __y) {
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
||||
#pragma reset woff 1174
|
||||
#pragma reset woff 1375
|
||||
#endif
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
@ -35,143 +35,160 @@ __STL_BEGIN_NAMESPACE
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
||||
#pragma set woff 1174
|
||||
#pragma set woff 1375
|
||||
#endif
|
||||
|
||||
#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
|
||||
template <class Key, class T, class Compare = less<Key>, class Alloc = alloc>
|
||||
template <class _Key, class _Tp, class _Compare = less<_Key>,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
|
||||
#else
|
||||
template <class Key, class T, class Compare, class Alloc = alloc>
|
||||
template <class _Key, class _Tp, class _Compare,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
|
||||
#endif
|
||||
class multimap {
|
||||
public:
|
||||
|
||||
// typedefs:
|
||||
|
||||
typedef Key key_type;
|
||||
typedef T data_type;
|
||||
typedef T mapped_type;
|
||||
typedef pair<const Key, T> value_type;
|
||||
typedef Compare key_compare;
|
||||
typedef _Key key_type;
|
||||
typedef _Tp data_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<const _Key, _Tp> value_type;
|
||||
typedef _Compare key_compare;
|
||||
|
||||
class value_compare : public binary_function<value_type, value_type, bool> {
|
||||
friend class multimap<Key, T, Compare, Alloc>;
|
||||
friend class multimap<_Key,_Tp,_Compare,_Alloc>;
|
||||
protected:
|
||||
Compare comp;
|
||||
value_compare(Compare c) : comp(c) {}
|
||||
_Compare _M_comp;
|
||||
value_compare(_Compare __c) : _M_comp(__c) {}
|
||||
public:
|
||||
bool operator()(const value_type& x, const value_type& y) const {
|
||||
return comp(x.first, y.first);
|
||||
bool operator()(const value_type& __x, const value_type& __y) const {
|
||||
return _M_comp(__x.first, __y.first);
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
typedef rb_tree<key_type, value_type,
|
||||
select1st<value_type>, key_compare, Alloc> rep_type;
|
||||
rep_type t; // red-black tree representing multimap
|
||||
typedef _Rb_tree<key_type, value_type,
|
||||
_Select1st<value_type>, key_compare, _Alloc> _Rep_type;
|
||||
_Rep_type _M_t; // red-black tree representing multimap
|
||||
public:
|
||||
typedef typename rep_type::pointer pointer;
|
||||
typedef typename rep_type::const_pointer const_pointer;
|
||||
typedef typename rep_type::reference reference;
|
||||
typedef typename rep_type::const_reference const_reference;
|
||||
typedef typename rep_type::iterator iterator;
|
||||
typedef typename rep_type::const_iterator const_iterator;
|
||||
typedef typename rep_type::reverse_iterator reverse_iterator;
|
||||
typedef typename rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename rep_type::size_type size_type;
|
||||
typedef typename rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::pointer pointer;
|
||||
typedef typename _Rep_type::const_pointer const_pointer;
|
||||
typedef typename _Rep_type::reference reference;
|
||||
typedef typename _Rep_type::const_reference const_reference;
|
||||
typedef typename _Rep_type::iterator iterator;
|
||||
typedef typename _Rep_type::const_iterator const_iterator;
|
||||
typedef typename _Rep_type::reverse_iterator reverse_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename _Rep_type::size_type size_type;
|
||||
typedef typename _Rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::allocator_type allocator_type;
|
||||
|
||||
// allocation/deallocation
|
||||
|
||||
multimap() : t(Compare()) { }
|
||||
explicit multimap(const Compare& comp) : t(comp) { }
|
||||
multimap() : _M_t(_Compare(), allocator_type()) { }
|
||||
explicit multimap(const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { }
|
||||
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
multimap(InputIterator first, InputIterator last)
|
||||
: t(Compare()) { t.insert_equal(first, last); }
|
||||
template <class _InputIterator>
|
||||
multimap(_InputIterator __first, _InputIterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
|
||||
template <class InputIterator>
|
||||
multimap(InputIterator first, InputIterator last, const Compare& comp)
|
||||
: t(comp) { t.insert_equal(first, last); }
|
||||
template <class _InputIterator>
|
||||
multimap(_InputIterator __first, _InputIterator __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
||||
#else
|
||||
multimap(const value_type* first, const value_type* last)
|
||||
: t(Compare()) { t.insert_equal(first, last); }
|
||||
multimap(const value_type* first, const value_type* last,
|
||||
const Compare& comp)
|
||||
: t(comp) { t.insert_equal(first, last); }
|
||||
multimap(const value_type* __first, const value_type* __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
multimap(const value_type* __first, const value_type* __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
||||
|
||||
multimap(const_iterator first, const_iterator last)
|
||||
: t(Compare()) { t.insert_equal(first, last); }
|
||||
multimap(const_iterator first, const_iterator last, const Compare& comp)
|
||||
: t(comp) { t.insert_equal(first, last); }
|
||||
multimap(const_iterator __first, const_iterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
multimap(const_iterator __first, const_iterator __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
||||
#endif /* __STL_MEMBER_TEMPLATES */
|
||||
|
||||
multimap(const multimap<Key, T, Compare, Alloc>& x) : t(x.t) { }
|
||||
multimap<Key, T, Compare, Alloc>&
|
||||
operator=(const multimap<Key, T, Compare, Alloc>& x) {
|
||||
t = x.t;
|
||||
multimap(const multimap<_Key,_Tp,_Compare,_Alloc>& __x) : _M_t(__x._M_t) { }
|
||||
multimap<_Key,_Tp,_Compare,_Alloc>&
|
||||
operator=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x) {
|
||||
_M_t = __x._M_t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// accessors:
|
||||
|
||||
key_compare key_comp() const { return t.key_comp(); }
|
||||
value_compare value_comp() const { return value_compare(t.key_comp()); }
|
||||
iterator begin() { return t.begin(); }
|
||||
const_iterator begin() const { return t.begin(); }
|
||||
iterator end() { return t.end(); }
|
||||
const_iterator end() const { return t.end(); }
|
||||
reverse_iterator rbegin() { return t.rbegin(); }
|
||||
const_reverse_iterator rbegin() const { return t.rbegin(); }
|
||||
reverse_iterator rend() { return t.rend(); }
|
||||
const_reverse_iterator rend() const { return t.rend(); }
|
||||
bool empty() const { return t.empty(); }
|
||||
size_type size() const { return t.size(); }
|
||||
size_type max_size() const { return t.max_size(); }
|
||||
void swap(multimap<Key, T, Compare, Alloc>& x) { t.swap(x.t); }
|
||||
key_compare key_comp() const { return _M_t.key_comp(); }
|
||||
value_compare value_comp() const { return value_compare(_M_t.key_comp()); }
|
||||
allocator_type get_allocator() const { return _M_t.get_allocator(); }
|
||||
|
||||
iterator begin() { return _M_t.begin(); }
|
||||
const_iterator begin() const { return _M_t.begin(); }
|
||||
iterator end() { return _M_t.end(); }
|
||||
const_iterator end() const { return _M_t.end(); }
|
||||
reverse_iterator rbegin() { return _M_t.rbegin(); }
|
||||
const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
|
||||
reverse_iterator rend() { return _M_t.rend(); }
|
||||
const_reverse_iterator rend() const { return _M_t.rend(); }
|
||||
bool empty() const { return _M_t.empty(); }
|
||||
size_type size() const { return _M_t.size(); }
|
||||
size_type max_size() const { return _M_t.max_size(); }
|
||||
void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }
|
||||
|
||||
// insert/erase
|
||||
|
||||
iterator insert(const value_type& x) { return t.insert_equal(x); }
|
||||
iterator insert(iterator position, const value_type& x) {
|
||||
return t.insert_equal(position, x);
|
||||
iterator insert(const value_type& __x) { return _M_t.insert_equal(__x); }
|
||||
iterator insert(iterator __position, const value_type& __x) {
|
||||
return _M_t.insert_equal(__position, __x);
|
||||
}
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last) {
|
||||
t.insert_equal(first, last);
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __first, _InputIterator __last) {
|
||||
_M_t.insert_equal(__first, __last);
|
||||
}
|
||||
#else
|
||||
void insert(const value_type* first, const value_type* last) {
|
||||
t.insert_equal(first, last);
|
||||
void insert(const value_type* __first, const value_type* __last) {
|
||||
_M_t.insert_equal(__first, __last);
|
||||
}
|
||||
void insert(const_iterator first, const_iterator last) {
|
||||
t.insert_equal(first, last);
|
||||
void insert(const_iterator __first, const_iterator __last) {
|
||||
_M_t.insert_equal(__first, __last);
|
||||
}
|
||||
#endif /* __STL_MEMBER_TEMPLATES */
|
||||
void erase(iterator position) { t.erase(position); }
|
||||
size_type erase(const key_type& x) { return t.erase(x); }
|
||||
void erase(iterator first, iterator last) { t.erase(first, last); }
|
||||
void clear() { t.clear(); }
|
||||
void erase(iterator __position) { _M_t.erase(__position); }
|
||||
size_type erase(const key_type& __x) { return _M_t.erase(__x); }
|
||||
void erase(iterator __first, iterator __last)
|
||||
{ _M_t.erase(__first, __last); }
|
||||
void clear() { _M_t.clear(); }
|
||||
|
||||
// multimap operations:
|
||||
|
||||
iterator find(const key_type& x) { return t.find(x); }
|
||||
const_iterator find(const key_type& x) const { return t.find(x); }
|
||||
size_type count(const key_type& x) const { return t.count(x); }
|
||||
iterator lower_bound(const key_type& x) {return t.lower_bound(x); }
|
||||
const_iterator lower_bound(const key_type& x) const {
|
||||
return t.lower_bound(x);
|
||||
iterator find(const key_type& __x) { return _M_t.find(__x); }
|
||||
const_iterator find(const key_type& __x) const { return _M_t.find(__x); }
|
||||
size_type count(const key_type& __x) const { return _M_t.count(__x); }
|
||||
iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); }
|
||||
const_iterator lower_bound(const key_type& __x) const {
|
||||
return _M_t.lower_bound(__x);
|
||||
}
|
||||
iterator upper_bound(const key_type& x) {return t.upper_bound(x); }
|
||||
const_iterator upper_bound(const key_type& x) const {
|
||||
return t.upper_bound(x);
|
||||
iterator upper_bound(const key_type& __x) {return _M_t.upper_bound(__x); }
|
||||
const_iterator upper_bound(const key_type& __x) const {
|
||||
return _M_t.upper_bound(__x);
|
||||
}
|
||||
pair<iterator,iterator> equal_range(const key_type& x) {
|
||||
return t.equal_range(x);
|
||||
pair<iterator,iterator> equal_range(const key_type& __x) {
|
||||
return _M_t.equal_range(__x);
|
||||
}
|
||||
pair<const_iterator,const_iterator> equal_range(const key_type& x) const {
|
||||
return t.equal_range(x);
|
||||
pair<const_iterator,const_iterator> equal_range(const key_type& __x) const {
|
||||
return _M_t.equal_range(__x);
|
||||
}
|
||||
friend bool operator== __STL_NULL_TMPL_ARGS (const multimap&,
|
||||
const multimap&);
|
||||
@ -179,30 +196,31 @@ public:
|
||||
const multimap&);
|
||||
};
|
||||
|
||||
template <class Key, class T, class Compare, class Alloc>
|
||||
inline bool operator==(const multimap<Key, T, Compare, Alloc>& x,
|
||||
const multimap<Key, T, Compare, Alloc>& y) {
|
||||
return x.t == y.t;
|
||||
template <class _Key, class _Tp, class _Compare, class _Alloc>
|
||||
inline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
|
||||
const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
|
||||
return __x._M_t == __y._M_t;
|
||||
}
|
||||
|
||||
template <class Key, class T, class Compare, class Alloc>
|
||||
inline bool operator<(const multimap<Key, T, Compare, Alloc>& x,
|
||||
const multimap<Key, T, Compare, Alloc>& y) {
|
||||
return x.t < y.t;
|
||||
template <class _Key, class _Tp, class _Compare, class _Alloc>
|
||||
inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
|
||||
const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
|
||||
return __x._M_t < __y._M_t;
|
||||
}
|
||||
|
||||
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
|
||||
template <class Key, class T, class Compare, class Alloc>
|
||||
inline void swap(multimap<Key, T, Compare, Alloc>& x,
|
||||
multimap<Key, T, Compare, Alloc>& y) {
|
||||
x.swap(y);
|
||||
template <class _Key, class _Tp, class _Compare, class _Alloc>
|
||||
inline void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x,
|
||||
multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
||||
#pragma reset woff 1174
|
||||
#pragma reset woff 1375
|
||||
#endif
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
@ -35,129 +35,152 @@ __STL_BEGIN_NAMESPACE
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
||||
#pragma set woff 1174
|
||||
#pragma set woff 1375
|
||||
#endif
|
||||
|
||||
#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
|
||||
template <class Key, class Compare = less<Key>, class Alloc = alloc>
|
||||
template <class _Key, class _Compare = less<_Key>,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Key) >
|
||||
#else
|
||||
template <class Key, class Compare, class Alloc = alloc>
|
||||
template <class _Key, class _Compare,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Key) >
|
||||
#endif
|
||||
class multiset {
|
||||
public:
|
||||
// typedefs:
|
||||
|
||||
typedef Key key_type;
|
||||
typedef Key value_type;
|
||||
typedef Compare key_compare;
|
||||
typedef Compare value_compare;
|
||||
typedef _Key key_type;
|
||||
typedef _Key value_type;
|
||||
typedef _Compare key_compare;
|
||||
typedef _Compare value_compare;
|
||||
private:
|
||||
typedef rb_tree<key_type, value_type,
|
||||
identity<value_type>, key_compare, Alloc> rep_type;
|
||||
rep_type t; // red-black tree representing multiset
|
||||
typedef _Rb_tree<key_type, value_type,
|
||||
_Identity<value_type>, key_compare, _Alloc> _Rep_type;
|
||||
_Rep_type _M_t; // red-black tree representing multiset
|
||||
public:
|
||||
typedef typename rep_type::const_pointer pointer;
|
||||
typedef typename rep_type::const_pointer const_pointer;
|
||||
typedef typename rep_type::const_reference reference;
|
||||
typedef typename rep_type::const_reference const_reference;
|
||||
typedef typename rep_type::const_iterator iterator;
|
||||
typedef typename rep_type::const_iterator const_iterator;
|
||||
typedef typename rep_type::const_reverse_iterator reverse_iterator;
|
||||
typedef typename rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename rep_type::size_type size_type;
|
||||
typedef typename rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::const_pointer pointer;
|
||||
typedef typename _Rep_type::const_pointer const_pointer;
|
||||
typedef typename _Rep_type::const_reference reference;
|
||||
typedef typename _Rep_type::const_reference const_reference;
|
||||
typedef typename _Rep_type::const_iterator iterator;
|
||||
typedef typename _Rep_type::const_iterator const_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename _Rep_type::size_type size_type;
|
||||
typedef typename _Rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::allocator_type allocator_type;
|
||||
|
||||
// allocation/deallocation
|
||||
|
||||
multiset() : t(Compare()) {}
|
||||
explicit multiset(const Compare& comp) : t(comp) {}
|
||||
multiset() : _M_t(_Compare(), allocator_type()) {}
|
||||
explicit multiset(const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) {}
|
||||
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
multiset(InputIterator first, InputIterator last)
|
||||
: t(Compare()) { t.insert_equal(first, last); }
|
||||
template <class InputIterator>
|
||||
multiset(InputIterator first, InputIterator last, const Compare& comp)
|
||||
: t(comp) { t.insert_equal(first, last); }
|
||||
#else
|
||||
multiset(const value_type* first, const value_type* last)
|
||||
: t(Compare()) { t.insert_equal(first, last); }
|
||||
multiset(const value_type* first, const value_type* last,
|
||||
const Compare& comp)
|
||||
: t(comp) { t.insert_equal(first, last); }
|
||||
|
||||
multiset(const_iterator first, const_iterator last)
|
||||
: t(Compare()) { t.insert_equal(first, last); }
|
||||
multiset(const_iterator first, const_iterator last, const Compare& comp)
|
||||
: t(comp) { t.insert_equal(first, last); }
|
||||
template <class _InputIterator>
|
||||
multiset(_InputIterator __first, _InputIterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
|
||||
template <class _InputIterator>
|
||||
multiset(_InputIterator __first, _InputIterator __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
||||
|
||||
#else
|
||||
|
||||
multiset(const value_type* __first, const value_type* __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
|
||||
multiset(const value_type* __first, const value_type* __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
||||
|
||||
multiset(const_iterator __first, const_iterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
|
||||
multiset(const_iterator __first, const_iterator __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
||||
|
||||
#endif /* __STL_MEMBER_TEMPLATES */
|
||||
|
||||
multiset(const multiset<Key, Compare, Alloc>& x) : t(x.t) {}
|
||||
multiset<Key, Compare, Alloc>&
|
||||
operator=(const multiset<Key, Compare, Alloc>& x) {
|
||||
t = x.t;
|
||||
multiset(const multiset<_Key,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {}
|
||||
multiset<_Key,_Compare,_Alloc>&
|
||||
operator=(const multiset<_Key,_Compare,_Alloc>& __x) {
|
||||
_M_t = __x._M_t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// accessors:
|
||||
|
||||
key_compare key_comp() const { return t.key_comp(); }
|
||||
value_compare value_comp() const { return t.key_comp(); }
|
||||
iterator begin() const { return t.begin(); }
|
||||
iterator end() const { return t.end(); }
|
||||
reverse_iterator rbegin() const { return t.rbegin(); }
|
||||
reverse_iterator rend() const { return t.rend(); }
|
||||
bool empty() const { return t.empty(); }
|
||||
size_type size() const { return t.size(); }
|
||||
size_type max_size() const { return t.max_size(); }
|
||||
void swap(multiset<Key, Compare, Alloc>& x) { t.swap(x.t); }
|
||||
key_compare key_comp() const { return _M_t.key_comp(); }
|
||||
value_compare value_comp() const { return _M_t.key_comp(); }
|
||||
allocator_type get_allocator() const { return _M_t.get_allocator(); }
|
||||
|
||||
iterator begin() const { return _M_t.begin(); }
|
||||
iterator end() const { return _M_t.end(); }
|
||||
reverse_iterator rbegin() const { return _M_t.rbegin(); }
|
||||
reverse_iterator rend() const { return _M_t.rend(); }
|
||||
bool empty() const { return _M_t.empty(); }
|
||||
size_type size() const { return _M_t.size(); }
|
||||
size_type max_size() const { return _M_t.max_size(); }
|
||||
void swap(multiset<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }
|
||||
|
||||
// insert/erase
|
||||
iterator insert(const value_type& x) {
|
||||
return t.insert_equal(x);
|
||||
iterator insert(const value_type& __x) {
|
||||
return _M_t.insert_equal(__x);
|
||||
}
|
||||
iterator insert(iterator position, const value_type& x) {
|
||||
typedef typename rep_type::iterator rep_iterator;
|
||||
return t.insert_equal((rep_iterator&)position, x);
|
||||
iterator insert(iterator __position, const value_type& __x) {
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
return _M_t.insert_equal((_Rep_iterator&)__position, __x);
|
||||
}
|
||||
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last) {
|
||||
t.insert_equal(first, last);
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __first, _InputIterator __last) {
|
||||
_M_t.insert_equal(__first, __last);
|
||||
}
|
||||
#else
|
||||
void insert(const value_type* first, const value_type* last) {
|
||||
t.insert_equal(first, last);
|
||||
void insert(const value_type* __first, const value_type* __last) {
|
||||
_M_t.insert_equal(__first, __last);
|
||||
}
|
||||
void insert(const_iterator first, const_iterator last) {
|
||||
t.insert_equal(first, last);
|
||||
void insert(const_iterator __first, const_iterator __last) {
|
||||
_M_t.insert_equal(__first, __last);
|
||||
}
|
||||
#endif /* __STL_MEMBER_TEMPLATES */
|
||||
void erase(iterator position) {
|
||||
typedef typename rep_type::iterator rep_iterator;
|
||||
t.erase((rep_iterator&)position);
|
||||
void erase(iterator __position) {
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
_M_t.erase((_Rep_iterator&)__position);
|
||||
}
|
||||
size_type erase(const key_type& x) {
|
||||
return t.erase(x);
|
||||
size_type erase(const key_type& __x) {
|
||||
return _M_t.erase(__x);
|
||||
}
|
||||
void erase(iterator first, iterator last) {
|
||||
typedef typename rep_type::iterator rep_iterator;
|
||||
t.erase((rep_iterator&)first, (rep_iterator&)last);
|
||||
void erase(iterator __first, iterator __last) {
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
_M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last);
|
||||
}
|
||||
void clear() { t.clear(); }
|
||||
void clear() { _M_t.clear(); }
|
||||
|
||||
// multiset operations:
|
||||
|
||||
iterator find(const key_type& x) const { return t.find(x); }
|
||||
size_type count(const key_type& x) const { return t.count(x); }
|
||||
iterator lower_bound(const key_type& x) const {
|
||||
return t.lower_bound(x);
|
||||
iterator find(const key_type& __x) const { return _M_t.find(__x); }
|
||||
size_type count(const key_type& __x) const { return _M_t.count(__x); }
|
||||
iterator lower_bound(const key_type& __x) const {
|
||||
return _M_t.lower_bound(__x);
|
||||
}
|
||||
iterator upper_bound(const key_type& x) const {
|
||||
return t.upper_bound(x);
|
||||
iterator upper_bound(const key_type& __x) const {
|
||||
return _M_t.upper_bound(__x);
|
||||
}
|
||||
pair<iterator,iterator> equal_range(const key_type& x) const {
|
||||
return t.equal_range(x);
|
||||
pair<iterator,iterator> equal_range(const key_type& __x) const {
|
||||
return _M_t.equal_range(__x);
|
||||
}
|
||||
friend bool operator== __STL_NULL_TMPL_ARGS (const multiset&,
|
||||
const multiset&);
|
||||
@ -165,30 +188,31 @@ public:
|
||||
const multiset&);
|
||||
};
|
||||
|
||||
template <class Key, class Compare, class Alloc>
|
||||
inline bool operator==(const multiset<Key, Compare, Alloc>& x,
|
||||
const multiset<Key, Compare, Alloc>& y) {
|
||||
return x.t == y.t;
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline bool operator==(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
const multiset<_Key,_Compare,_Alloc>& __y) {
|
||||
return __x._M_t == __y._M_t;
|
||||
}
|
||||
|
||||
template <class Key, class Compare, class Alloc>
|
||||
inline bool operator<(const multiset<Key, Compare, Alloc>& x,
|
||||
const multiset<Key, Compare, Alloc>& y) {
|
||||
return x.t < y.t;
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
const multiset<_Key,_Compare,_Alloc>& __y) {
|
||||
return __x._M_t < __y._M_t;
|
||||
}
|
||||
|
||||
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
|
||||
template <class Key, class Compare, class Alloc>
|
||||
inline void swap(multiset<Key, Compare, Alloc>& x,
|
||||
multiset<Key, Compare, Alloc>& y) {
|
||||
x.swap(y);
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline void swap(multiset<_Key,_Compare,_Alloc>& __x,
|
||||
multiset<_Key,_Compare,_Alloc>& __y) {
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
||||
#pragma reset woff 1174
|
||||
#pragma reset woff 1375
|
||||
#endif
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
@ -34,157 +34,200 @@
|
||||
|
||||
__STL_BEGIN_NAMESPACE
|
||||
|
||||
template <class InputIterator, class T>
|
||||
T accumulate(InputIterator first, InputIterator last, T init) {
|
||||
for ( ; first != last; ++first)
|
||||
init = init + *first;
|
||||
return init;
|
||||
template <class _InputIterator, class _Tp>
|
||||
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
|
||||
{
|
||||
for ( ; __first != __last; ++__first)
|
||||
__init = __init + *__first;
|
||||
return __init;
|
||||
}
|
||||
|
||||
template <class InputIterator, class T, class BinaryOperation>
|
||||
T accumulate(InputIterator first, InputIterator last, T init,
|
||||
BinaryOperation binary_op) {
|
||||
for ( ; first != last; ++first)
|
||||
init = binary_op(init, *first);
|
||||
return init;
|
||||
template <class _InputIterator, class _Tp, class _BinaryOperation>
|
||||
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
|
||||
_BinaryOperation __binary_op)
|
||||
{
|
||||
for ( ; __first != __last; ++__first)
|
||||
__init = __binary_op(__init, *__first);
|
||||
return __init;
|
||||
}
|
||||
|
||||
template <class InputIterator1, class InputIterator2, class T>
|
||||
T inner_product(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, T init) {
|
||||
for ( ; first1 != last1; ++first1, ++first2)
|
||||
init = init + (*first1 * *first2);
|
||||
return init;
|
||||
template <class _InputIterator1, class _InputIterator2, class _Tp>
|
||||
_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _Tp __init)
|
||||
{
|
||||
for ( ; __first1 != __last1; ++__first1, ++__first2)
|
||||
__init = __init + (*__first1 * *__first2);
|
||||
return __init;
|
||||
}
|
||||
|
||||
template <class InputIterator1, class InputIterator2, class T,
|
||||
class BinaryOperation1, class BinaryOperation2>
|
||||
T inner_product(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, T init, BinaryOperation1 binary_op1,
|
||||
BinaryOperation2 binary_op2) {
|
||||
for ( ; first1 != last1; ++first1, ++first2)
|
||||
init = binary_op1(init, binary_op2(*first1, *first2));
|
||||
return init;
|
||||
template <class _InputIterator1, class _InputIterator2, class _Tp,
|
||||
class _BinaryOperation1, class _BinaryOperation2>
|
||||
_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _Tp __init,
|
||||
_BinaryOperation1 __binary_op1,
|
||||
_BinaryOperation2 __binary_op2)
|
||||
{
|
||||
for ( ; __first1 != __last1; ++__first1, ++__first2)
|
||||
__init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
|
||||
return __init;
|
||||
}
|
||||
|
||||
template <class InputIterator, class OutputIterator, class T>
|
||||
OutputIterator __partial_sum(InputIterator first, InputIterator last,
|
||||
OutputIterator result, T*) {
|
||||
T value = *first;
|
||||
while (++first != last) {
|
||||
value = value + *first;
|
||||
*++result = value;
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp>
|
||||
_OutputIterator
|
||||
__partial_sum(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp*)
|
||||
{
|
||||
_Tp __value = *__first;
|
||||
while (++__first != __last) {
|
||||
__value = __value + *__first;
|
||||
*++__result = __value;
|
||||
}
|
||||
return ++result;
|
||||
return ++__result;
|
||||
}
|
||||
|
||||
template <class InputIterator, class OutputIterator>
|
||||
OutputIterator partial_sum(InputIterator first, InputIterator last,
|
||||
OutputIterator result) {
|
||||
if (first == last) return result;
|
||||
*result = *first;
|
||||
return __partial_sum(first, last, result, value_type(first));
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
_OutputIterator
|
||||
partial_sum(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result)
|
||||
{
|
||||
if (__first == __last) return __result;
|
||||
*__result = *__first;
|
||||
return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first));
|
||||
}
|
||||
|
||||
template <class InputIterator, class OutputIterator, class T,
|
||||
class BinaryOperation>
|
||||
OutputIterator __partial_sum(InputIterator first, InputIterator last,
|
||||
OutputIterator result, T*,
|
||||
BinaryOperation binary_op) {
|
||||
T value = *first;
|
||||
while (++first != last) {
|
||||
value = binary_op(value, *first);
|
||||
*++result = value;
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp,
|
||||
class _BinaryOperation>
|
||||
_OutputIterator
|
||||
__partial_sum(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp*, _BinaryOperation __binary_op)
|
||||
{
|
||||
_Tp __value = *__first;
|
||||
while (++__first != __last) {
|
||||
__value = __binary_op(__value, *__first);
|
||||
*++__result = __value;
|
||||
}
|
||||
return ++result;
|
||||
return ++__result;
|
||||
}
|
||||
|
||||
template <class InputIterator, class OutputIterator, class BinaryOperation>
|
||||
OutputIterator partial_sum(InputIterator first, InputIterator last,
|
||||
OutputIterator result, BinaryOperation binary_op) {
|
||||
if (first == last) return result;
|
||||
*result = *first;
|
||||
return __partial_sum(first, last, result, value_type(first), binary_op);
|
||||
template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
|
||||
_OutputIterator
|
||||
partial_sum(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOperation __binary_op)
|
||||
{
|
||||
if (__first == __last) return __result;
|
||||
*__result = *__first;
|
||||
return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first),
|
||||
__binary_op);
|
||||
}
|
||||
|
||||
template <class InputIterator, class OutputIterator, class T>
|
||||
OutputIterator __adjacent_difference(InputIterator first, InputIterator last,
|
||||
OutputIterator result, T*) {
|
||||
T value = *first;
|
||||
while (++first != last) {
|
||||
T tmp = *first;
|
||||
*++result = tmp - value;
|
||||
value = tmp;
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp>
|
||||
_OutputIterator
|
||||
__adjacent_difference(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp*)
|
||||
{
|
||||
_Tp __value = *__first;
|
||||
while (++__first != __last) {
|
||||
_Tp __tmp = *__first;
|
||||
*++__result = __tmp - __value;
|
||||
__value = __tmp;
|
||||
}
|
||||
return ++result;
|
||||
return ++__result;
|
||||
}
|
||||
|
||||
template <class InputIterator, class OutputIterator>
|
||||
OutputIterator adjacent_difference(InputIterator first, InputIterator last,
|
||||
OutputIterator result) {
|
||||
if (first == last) return result;
|
||||
*result = *first;
|
||||
return __adjacent_difference(first, last, result, value_type(first));
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
_OutputIterator
|
||||
adjacent_difference(_InputIterator __first,
|
||||
_InputIterator __last, _OutputIterator __result)
|
||||
{
|
||||
if (__first == __last) return __result;
|
||||
*__result = *__first;
|
||||
return __adjacent_difference(__first, __last, __result,
|
||||
__VALUE_TYPE(__first));
|
||||
}
|
||||
|
||||
template <class InputIterator, class OutputIterator, class T,
|
||||
class BinaryOperation>
|
||||
OutputIterator __adjacent_difference(InputIterator first, InputIterator last,
|
||||
OutputIterator result, T*,
|
||||
BinaryOperation binary_op) {
|
||||
T value = *first;
|
||||
while (++first != last) {
|
||||
T tmp = *first;
|
||||
*++result = binary_op(tmp, value);
|
||||
value = tmp;
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp,
|
||||
class _BinaryOperation>
|
||||
_OutputIterator
|
||||
__adjacent_difference(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp*,
|
||||
_BinaryOperation __binary_op) {
|
||||
_Tp __value = *__first;
|
||||
while (++__first != __last) {
|
||||
_Tp __tmp = *__first;
|
||||
*++__result = __binary_op(__tmp, __value);
|
||||
__value = __tmp;
|
||||
}
|
||||
return ++result;
|
||||
return ++__result;
|
||||
}
|
||||
|
||||
template <class InputIterator, class OutputIterator, class BinaryOperation>
|
||||
OutputIterator adjacent_difference(InputIterator first, InputIterator last,
|
||||
OutputIterator result,
|
||||
BinaryOperation binary_op) {
|
||||
if (first == last) return result;
|
||||
*result = *first;
|
||||
return __adjacent_difference(first, last, result, value_type(first),
|
||||
binary_op);
|
||||
template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
|
||||
_OutputIterator
|
||||
adjacent_difference(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOperation __binary_op)
|
||||
{
|
||||
if (__first == __last) return __result;
|
||||
*__result = *__first;
|
||||
return __adjacent_difference(__first, __last, __result,
|
||||
__VALUE_TYPE(__first),
|
||||
__binary_op);
|
||||
}
|
||||
|
||||
// Returns x ** n, where n >= 0. Note that "multiplication"
|
||||
// is required to be associative, but not necessarily commutative.
|
||||
|
||||
template <class T, class Integer, class MonoidOperation>
|
||||
T power(T x, Integer n, MonoidOperation op) {
|
||||
if (n == 0)
|
||||
return identity_element(op);
|
||||
// Returns __x ** __n, where __n >= 0. _Note that "multiplication"
|
||||
// is required to be associative, but not necessarily commutative.
|
||||
|
||||
|
||||
template <class _Tp, class _Integer, class _MonoidOperation>
|
||||
_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __oper)
|
||||
{
|
||||
if (__n == 0)
|
||||
return identity_element(__oper);
|
||||
else {
|
||||
while ((n & 1) == 0) {
|
||||
n >>= 1;
|
||||
x = op(x, x);
|
||||
while ((__n & 1) == 0) {
|
||||
__n >>= 1;
|
||||
__x = __oper(__x, __x);
|
||||
}
|
||||
|
||||
T result = x;
|
||||
n >>= 1;
|
||||
while (n != 0) {
|
||||
x = op(x, x);
|
||||
if ((n & 1) != 0)
|
||||
result = op(result, x);
|
||||
n >>= 1;
|
||||
_Tp __result = __x;
|
||||
__n >>= 1;
|
||||
while (__n != 0) {
|
||||
__x = __oper(__x, __x);
|
||||
if ((__n & 1) != 0)
|
||||
__result = __oper(__result, __x);
|
||||
__n >>= 1;
|
||||
}
|
||||
return result;
|
||||
return __result;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class Integer>
|
||||
inline T power(T x, Integer n) {
|
||||
return power(x, n, multiplies<T>());
|
||||
template <class _Tp, class _Integer>
|
||||
inline _Tp __power(_Tp __x, _Integer __n)
|
||||
{
|
||||
return __power(__x, __n, multiplies<_Tp>());
|
||||
}
|
||||
|
||||
// Alias for the internal name __power. Note that power is an extension,
|
||||
// not part of the C++ standard.
|
||||
|
||||
template <class ForwardIterator, class T>
|
||||
void iota(ForwardIterator first, ForwardIterator last, T value) {
|
||||
while (first != last) *first++ = value++;
|
||||
template <class _Tp, class _Integer, class _MonoidOperation>
|
||||
inline _Tp power(_Tp __x, _Integer __n, _MonoidOperation __oper)
|
||||
{
|
||||
return __power(__x, __n, __oper);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Integer>
|
||||
inline _Tp power(_Tp __x, _Integer __n)
|
||||
{
|
||||
return __power(__x, __n);
|
||||
}
|
||||
|
||||
// iota is not part of the C++ standard. It is an extension.
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
void
|
||||
iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
|
||||
{
|
||||
while (__first != __last)
|
||||
*__first++ = __value++;
|
||||
}
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
@ -33,35 +33,39 @@
|
||||
|
||||
__STL_BEGIN_NAMESPACE
|
||||
|
||||
template <class T1, class T2>
|
||||
template <class _T1, class _T2>
|
||||
struct pair {
|
||||
typedef T1 first_type;
|
||||
typedef T2 second_type;
|
||||
typedef _T1 first_type;
|
||||
typedef _T2 second_type;
|
||||
|
||||
T1 first;
|
||||
T2 second;
|
||||
pair() : first(T1()), second(T2()) {}
|
||||
pair(const T1& a, const T2& b) : first(a), second(b) {}
|
||||
_T1 first;
|
||||
_T2 second;
|
||||
pair() : first(_T1()), second(_T2()) {}
|
||||
pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
|
||||
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class U1, class U2>
|
||||
pair(const pair<U1, U2>& p) : first(p.first), second(p.second) {}
|
||||
template <class _U1, class _U2>
|
||||
pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class T1, class T2>
|
||||
inline bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y) {
|
||||
return x.first == y.first && x.second == y.second;
|
||||
template <class _T1, class _T2>
|
||||
inline bool operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
|
||||
{
|
||||
return __x.first == __y.first && __x.second == __y.second;
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
inline bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y) {
|
||||
return x.first < y.first || (!(y.first < x.first) && x.second < y.second);
|
||||
template <class _T1, class _T2>
|
||||
inline bool operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
|
||||
{
|
||||
return __x.first < __y.first ||
|
||||
(!(__y.first < __x.first) && __x.second < __y.second);
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
inline pair<T1, T2> make_pair(const T1& x, const T2& y) {
|
||||
return pair<T1, T2>(x, y);
|
||||
template <class _T1, class _T2>
|
||||
inline pair<_T1, _T2> make_pair(const _T1& __x, const _T2& __y)
|
||||
{
|
||||
return pair<_T1, _T2>(__x, __y);
|
||||
}
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
@ -34,82 +34,150 @@
|
||||
__STL_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
|
||||
template <class T, class Sequence = deque<T> >
|
||||
template <class _Tp, class _Sequence = deque<_Tp> >
|
||||
#else
|
||||
template <class T, class Sequence>
|
||||
template <class _Tp, class _Sequence>
|
||||
#endif
|
||||
class queue {
|
||||
friend bool operator== __STL_NULL_TMPL_ARGS (const queue& x, const queue& y);
|
||||
friend bool operator< __STL_NULL_TMPL_ARGS (const queue& x, const queue& y);
|
||||
friend bool operator== __STL_NULL_TMPL_ARGS (const queue&, const queue&);
|
||||
friend bool operator< __STL_NULL_TMPL_ARGS (const queue&, const queue&);
|
||||
public:
|
||||
typedef typename Sequence::value_type value_type;
|
||||
typedef typename Sequence::size_type size_type;
|
||||
typedef typename Sequence::reference reference;
|
||||
typedef typename Sequence::const_reference const_reference;
|
||||
typedef typename _Sequence::value_type value_type;
|
||||
typedef typename _Sequence::size_type size_type;
|
||||
typedef _Sequence container_type;
|
||||
|
||||
typedef typename _Sequence::reference reference;
|
||||
typedef typename _Sequence::const_reference const_reference;
|
||||
protected:
|
||||
Sequence c;
|
||||
_Sequence c;
|
||||
public:
|
||||
queue() : c() {}
|
||||
explicit queue(const _Sequence& __c) : c(__c) {}
|
||||
|
||||
bool empty() const { return c.empty(); }
|
||||
size_type size() const { return c.size(); }
|
||||
reference front() { return c.front(); }
|
||||
const_reference front() const { return c.front(); }
|
||||
reference back() { return c.back(); }
|
||||
const_reference back() const { return c.back(); }
|
||||
void push(const value_type& x) { c.push_back(x); }
|
||||
void push(const value_type& __x) { c.push_back(__x); }
|
||||
void pop() { c.pop_front(); }
|
||||
};
|
||||
|
||||
template <class T, class Sequence>
|
||||
bool operator==(const queue<T, Sequence>& x, const queue<T, Sequence>& y) {
|
||||
return x.c == y.c;
|
||||
template <class _Tp, class _Sequence>
|
||||
bool
|
||||
operator==(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
|
||||
{
|
||||
return __x.c == __y.c;
|
||||
}
|
||||
|
||||
template <class T, class Sequence>
|
||||
bool operator<(const queue<T, Sequence>& x, const queue<T, Sequence>& y) {
|
||||
return x.c < y.c;
|
||||
template <class _Tp, class _Sequence>
|
||||
bool
|
||||
operator<(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
|
||||
{
|
||||
return __x.c < __y.c;
|
||||
}
|
||||
|
||||
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
|
||||
template <class _Tp, class _Sequence>
|
||||
bool
|
||||
operator!=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
|
||||
{
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Sequence>
|
||||
bool
|
||||
operator>(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
|
||||
{
|
||||
return __y < __x;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Sequence>
|
||||
bool
|
||||
operator<=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
|
||||
{
|
||||
return !(__y < __x);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Sequence>
|
||||
bool
|
||||
operator>=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
|
||||
{
|
||||
return !(__x < __y);
|
||||
}
|
||||
|
||||
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
|
||||
#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
|
||||
template <class T, class Sequence = vector<T>,
|
||||
class Compare = less<typename Sequence::value_type> >
|
||||
template <class _Tp, class _Sequence = vector<_Tp>,
|
||||
class _Compare = less<typename _Sequence::value_type> >
|
||||
#else
|
||||
template <class T, class Sequence, class Compare>
|
||||
template <class _Tp, class _Sequence, class _Compare>
|
||||
#endif
|
||||
class priority_queue {
|
||||
public:
|
||||
typedef typename Sequence::value_type value_type;
|
||||
typedef typename Sequence::size_type size_type;
|
||||
typedef typename Sequence::reference reference;
|
||||
typedef typename Sequence::const_reference const_reference;
|
||||
typedef typename _Sequence::value_type value_type;
|
||||
typedef typename _Sequence::size_type size_type;
|
||||
typedef _Sequence container_type;
|
||||
|
||||
typedef typename _Sequence::reference reference;
|
||||
typedef typename _Sequence::const_reference const_reference;
|
||||
protected:
|
||||
Sequence c;
|
||||
Compare comp;
|
||||
_Sequence c;
|
||||
_Compare comp;
|
||||
public:
|
||||
priority_queue() : c() {}
|
||||
explicit priority_queue(const Compare& x) : c(), comp(x) {}
|
||||
explicit priority_queue(const _Compare& __x) : c(), comp(__x) {}
|
||||
priority_queue(const _Compare& __x, const _Sequence& __s)
|
||||
: c(__s), comp(__x)
|
||||
{ make_heap(c.begin(), c.end(), comp); }
|
||||
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
priority_queue(InputIterator first, InputIterator last, const Compare& x)
|
||||
: c(first, last), comp(x) { make_heap(c.begin(), c.end(), comp); }
|
||||
template <class InputIterator>
|
||||
priority_queue(InputIterator first, InputIterator last)
|
||||
: c(first, last) { make_heap(c.begin(), c.end(), comp); }
|
||||
#else /* __STL_MEMBER_TEMPLATES */
|
||||
priority_queue(const value_type* first, const value_type* last,
|
||||
const Compare& x) : c(first, last), comp(x) {
|
||||
template <class _InputIterator>
|
||||
priority_queue(_InputIterator __first, _InputIterator __last)
|
||||
: c(__first, __last) { make_heap(c.begin(), c.end(), comp); }
|
||||
|
||||
template <class _InputIterator>
|
||||
priority_queue(_InputIterator __first,
|
||||
_InputIterator __last, const _Compare& __x)
|
||||
: c(__first, __last), comp(__x)
|
||||
{ make_heap(c.begin(), c.end(), comp); }
|
||||
|
||||
template <class _InputIterator>
|
||||
priority_queue(_InputIterator __first, _InputIterator __last,
|
||||
const _Compare& __x, const _Sequence& __s)
|
||||
: c(__s), comp(__x)
|
||||
{
|
||||
c.insert(c.end(), __first, __last);
|
||||
make_heap(c.begin(), c.end(), comp);
|
||||
}
|
||||
|
||||
#else /* __STL_MEMBER_TEMPLATES */
|
||||
priority_queue(const value_type* __first, const value_type* __last)
|
||||
: c(__first, __last) { make_heap(c.begin(), c.end(), comp); }
|
||||
|
||||
priority_queue(const value_type* __first, const value_type* __last,
|
||||
const _Compare& __x)
|
||||
: c(__first, __last), comp(__x)
|
||||
{ make_heap(c.begin(), c.end(), comp); }
|
||||
|
||||
priority_queue(const value_type* __first, const value_type* __last,
|
||||
const _Compare& __x, const _Sequence& __c)
|
||||
: c(__c), comp(__x)
|
||||
{
|
||||
c.insert(c.end(), __first, __last);
|
||||
make_heap(c.begin(), c.end(), comp);
|
||||
}
|
||||
priority_queue(const value_type* first, const value_type* last)
|
||||
: c(first, last) { make_heap(c.begin(), c.end(), comp); }
|
||||
#endif /* __STL_MEMBER_TEMPLATES */
|
||||
|
||||
bool empty() const { return c.empty(); }
|
||||
size_type size() const { return c.size(); }
|
||||
const_reference top() const { return c.front(); }
|
||||
void push(const value_type& x) {
|
||||
void push(const value_type& __x) {
|
||||
__STL_TRY {
|
||||
c.push_back(x);
|
||||
c.push_back(__x);
|
||||
push_heap(c.begin(), c.end(), comp);
|
||||
}
|
||||
__STL_UNWIND(c.clear());
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H
|
||||
@ -33,10 +33,10 @@
|
||||
|
||||
__STL_BEGIN_NAMESPACE
|
||||
|
||||
template <class ForwardIterator, class T>
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
class raw_storage_iterator {
|
||||
protected:
|
||||
ForwardIterator iter;
|
||||
_ForwardIterator _M_iter;
|
||||
public:
|
||||
typedef output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
@ -44,38 +44,38 @@ public:
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
|
||||
explicit raw_storage_iterator(ForwardIterator x) : iter(x) {}
|
||||
raw_storage_iterator<ForwardIterator, T>& operator*() { return *this; }
|
||||
raw_storage_iterator<ForwardIterator, T>& operator=(const T& element) {
|
||||
construct(&*iter, element);
|
||||
explicit raw_storage_iterator(_ForwardIterator __x) : _M_iter(__x) {}
|
||||
raw_storage_iterator& operator*() { return *this; }
|
||||
raw_storage_iterator& operator=(const _Tp& __element) {
|
||||
construct(&*_M_iter, __element);
|
||||
return *this;
|
||||
}
|
||||
raw_storage_iterator<ForwardIterator, T>& operator++() {
|
||||
++iter;
|
||||
raw_storage_iterator<_ForwardIterator, _Tp>& operator++() {
|
||||
++_M_iter;
|
||||
return *this;
|
||||
}
|
||||
raw_storage_iterator<ForwardIterator, T> operator++(int) {
|
||||
raw_storage_iterator<ForwardIterator, T> tmp = *this;
|
||||
++iter;
|
||||
return tmp;
|
||||
raw_storage_iterator<_ForwardIterator, _Tp> operator++(int) {
|
||||
raw_storage_iterator<_ForwardIterator, _Tp> __tmp = *this;
|
||||
++_M_iter;
|
||||
return __tmp;
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION
|
||||
|
||||
template <class ForwardIterator, class T>
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
inline output_iterator_tag
|
||||
iterator_category(const raw_storage_iterator<ForwardIterator, T>&)
|
||||
iterator_category(const raw_storage_iterator<_ForwardIterator, _Tp>&)
|
||||
{
|
||||
return output_iterator_tag();
|
||||
}
|
||||
|
||||
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
|
||||
|
||||
#endif /* __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H */
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
||||
#endif /* __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
@ -33,24 +33,24 @@
|
||||
|
||||
__STL_BEGIN_RELOPS_NAMESPACE
|
||||
|
||||
template <class T>
|
||||
inline bool operator!=(const T& x, const T& y) {
|
||||
return !(x == y);
|
||||
template <class _Tp>
|
||||
inline bool operator!=(const _Tp& __x, const _Tp& __y) {
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool operator>(const T& x, const T& y) {
|
||||
return y < x;
|
||||
template <class _Tp>
|
||||
inline bool operator>(const _Tp& __x, const _Tp& __y) {
|
||||
return __y < __x;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool operator<=(const T& x, const T& y) {
|
||||
return !(y < x);
|
||||
template <class _Tp>
|
||||
inline bool operator<=(const _Tp& __x, const _Tp& __y) {
|
||||
return !(__y < __x);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool operator>=(const T& x, const T& y) {
|
||||
return !(x < y);
|
||||
template <class _Tp>
|
||||
inline bool operator>=(const _Tp& __x, const _Tp& __y) {
|
||||
return !(__x < __y);
|
||||
}
|
||||
|
||||
__STL_END_RELOPS_NAMESPACE
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -35,158 +35,176 @@ __STL_BEGIN_NAMESPACE
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
||||
#pragma set woff 1174
|
||||
#pragma set woff 1375
|
||||
#endif
|
||||
|
||||
#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
|
||||
template <class Key, class Compare = less<Key>, class Alloc = alloc>
|
||||
template <class _Key, class _Compare = less<_Key>,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Key) >
|
||||
#else
|
||||
template <class Key, class Compare, class Alloc = alloc>
|
||||
template <class _Key, class _Compare,
|
||||
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Key) >
|
||||
#endif
|
||||
class set {
|
||||
public:
|
||||
// typedefs:
|
||||
|
||||
typedef Key key_type;
|
||||
typedef Key value_type;
|
||||
typedef Compare key_compare;
|
||||
typedef Compare value_compare;
|
||||
typedef _Key key_type;
|
||||
typedef _Key value_type;
|
||||
typedef _Compare key_compare;
|
||||
typedef _Compare value_compare;
|
||||
private:
|
||||
typedef rb_tree<key_type, value_type,
|
||||
identity<value_type>, key_compare, Alloc> rep_type;
|
||||
rep_type t; // red-black tree representing set
|
||||
typedef _Rb_tree<key_type, value_type,
|
||||
_Identity<value_type>, key_compare, _Alloc> _Rep_type;
|
||||
_Rep_type _M_t; // red-black tree representing set
|
||||
public:
|
||||
typedef typename rep_type::const_pointer pointer;
|
||||
typedef typename rep_type::const_pointer const_pointer;
|
||||
typedef typename rep_type::const_reference reference;
|
||||
typedef typename rep_type::const_reference const_reference;
|
||||
typedef typename rep_type::const_iterator iterator;
|
||||
typedef typename rep_type::const_iterator const_iterator;
|
||||
typedef typename rep_type::const_reverse_iterator reverse_iterator;
|
||||
typedef typename rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename rep_type::size_type size_type;
|
||||
typedef typename rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::const_pointer pointer;
|
||||
typedef typename _Rep_type::const_pointer const_pointer;
|
||||
typedef typename _Rep_type::const_reference reference;
|
||||
typedef typename _Rep_type::const_reference const_reference;
|
||||
typedef typename _Rep_type::const_iterator iterator;
|
||||
typedef typename _Rep_type::const_iterator const_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename _Rep_type::size_type size_type;
|
||||
typedef typename _Rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::allocator_type allocator_type;
|
||||
|
||||
// allocation/deallocation
|
||||
|
||||
set() : t(Compare()) {}
|
||||
explicit set(const Compare& comp) : t(comp) {}
|
||||
set() : _M_t(_Compare(), allocator_type()) {}
|
||||
explicit set(const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) {}
|
||||
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
set(InputIterator first, InputIterator last)
|
||||
: t(Compare()) { t.insert_unique(first, last); }
|
||||
template <class _InputIterator>
|
||||
set(_InputIterator __first, _InputIterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
template <class InputIterator>
|
||||
set(InputIterator first, InputIterator last, const Compare& comp)
|
||||
: t(comp) { t.insert_unique(first, last); }
|
||||
template <class _InputIterator>
|
||||
set(_InputIterator __first, _InputIterator __last, const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
||||
#else
|
||||
set(const value_type* first, const value_type* last)
|
||||
: t(Compare()) { t.insert_unique(first, last); }
|
||||
set(const value_type* first, const value_type* last, const Compare& comp)
|
||||
: t(comp) { t.insert_unique(first, last); }
|
||||
set(const value_type* __first, const value_type* __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
set(const_iterator first, const_iterator last)
|
||||
: t(Compare()) { t.insert_unique(first, last); }
|
||||
set(const_iterator first, const_iterator last, const Compare& comp)
|
||||
: t(comp) { t.insert_unique(first, last); }
|
||||
set(const value_type* __first,
|
||||
const value_type* __last, const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
||||
|
||||
set(const_iterator __first, const_iterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
set(const_iterator __first, const_iterator __last, const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
||||
#endif /* __STL_MEMBER_TEMPLATES */
|
||||
|
||||
set(const set<Key, Compare, Alloc>& x) : t(x.t) {}
|
||||
set<Key, Compare, Alloc>& operator=(const set<Key, Compare, Alloc>& x) {
|
||||
t = x.t;
|
||||
set(const set<_Key,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {}
|
||||
set<_Key,_Compare,_Alloc>& operator=(const set<_Key, _Compare, _Alloc>& __x)
|
||||
{
|
||||
_M_t = __x._M_t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// accessors:
|
||||
|
||||
key_compare key_comp() const { return t.key_comp(); }
|
||||
value_compare value_comp() const { return t.key_comp(); }
|
||||
iterator begin() const { return t.begin(); }
|
||||
iterator end() const { return t.end(); }
|
||||
reverse_iterator rbegin() const { return t.rbegin(); }
|
||||
reverse_iterator rend() const { return t.rend(); }
|
||||
bool empty() const { return t.empty(); }
|
||||
size_type size() const { return t.size(); }
|
||||
size_type max_size() const { return t.max_size(); }
|
||||
void swap(set<Key, Compare, Alloc>& x) { t.swap(x.t); }
|
||||
key_compare key_comp() const { return _M_t.key_comp(); }
|
||||
value_compare value_comp() const { return _M_t.key_comp(); }
|
||||
allocator_type get_allocator() const { return _M_t.get_allocator(); }
|
||||
|
||||
iterator begin() const { return _M_t.begin(); }
|
||||
iterator end() const { return _M_t.end(); }
|
||||
reverse_iterator rbegin() const { return _M_t.rbegin(); }
|
||||
reverse_iterator rend() const { return _M_t.rend(); }
|
||||
bool empty() const { return _M_t.empty(); }
|
||||
size_type size() const { return _M_t.size(); }
|
||||
size_type max_size() const { return _M_t.max_size(); }
|
||||
void swap(set<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }
|
||||
|
||||
// insert/erase
|
||||
typedef pair<iterator, bool> pair_iterator_bool;
|
||||
pair<iterator,bool> insert(const value_type& x) {
|
||||
pair<typename rep_type::iterator, bool> p = t.insert_unique(x);
|
||||
return pair<iterator, bool>(p.first, p.second);
|
||||
pair<iterator,bool> insert(const value_type& __x) {
|
||||
pair<typename _Rep_type::iterator, bool> __p = _M_t.insert_unique(__x);
|
||||
return pair<iterator, bool>(__p.first, __p.second);
|
||||
}
|
||||
iterator insert(iterator position, const value_type& x) {
|
||||
typedef typename rep_type::iterator rep_iterator;
|
||||
return t.insert_unique((rep_iterator&)position, x);
|
||||
iterator insert(iterator __position, const value_type& __x) {
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
return _M_t.insert_unique((_Rep_iterator&)__position, __x);
|
||||
}
|
||||
#ifdef __STL_MEMBER_TEMPLATES
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last) {
|
||||
t.insert_unique(first, last);
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __first, _InputIterator __last) {
|
||||
_M_t.insert_unique(__first, __last);
|
||||
}
|
||||
#else
|
||||
void insert(const_iterator first, const_iterator last) {
|
||||
t.insert_unique(first, last);
|
||||
void insert(const_iterator __first, const_iterator __last) {
|
||||
_M_t.insert_unique(__first, __last);
|
||||
}
|
||||
void insert(const value_type* first, const value_type* last) {
|
||||
t.insert_unique(first, last);
|
||||
void insert(const value_type* __first, const value_type* __last) {
|
||||
_M_t.insert_unique(__first, __last);
|
||||
}
|
||||
#endif /* __STL_MEMBER_TEMPLATES */
|
||||
void erase(iterator position) {
|
||||
typedef typename rep_type::iterator rep_iterator;
|
||||
t.erase((rep_iterator&)position);
|
||||
void erase(iterator __position) {
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
_M_t.erase((_Rep_iterator&)__position);
|
||||
}
|
||||
size_type erase(const key_type& x) {
|
||||
return t.erase(x);
|
||||
size_type erase(const key_type& __x) {
|
||||
return _M_t.erase(__x);
|
||||
}
|
||||
void erase(iterator first, iterator last) {
|
||||
typedef typename rep_type::iterator rep_iterator;
|
||||
t.erase((rep_iterator&)first, (rep_iterator&)last);
|
||||
void erase(iterator __first, iterator __last) {
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
_M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last);
|
||||
}
|
||||
void clear() { t.clear(); }
|
||||
void clear() { _M_t.clear(); }
|
||||
|
||||
// set operations:
|
||||
|
||||
iterator find(const key_type& x) const { return t.find(x); }
|
||||
size_type count(const key_type& x) const { return t.count(x); }
|
||||
iterator lower_bound(const key_type& x) const {
|
||||
return t.lower_bound(x);
|
||||
iterator find(const key_type& __x) const { return _M_t.find(__x); }
|
||||
size_type count(const key_type& __x) const { return _M_t.count(__x); }
|
||||
iterator lower_bound(const key_type& __x) const {
|
||||
return _M_t.lower_bound(__x);
|
||||
}
|
||||
iterator upper_bound(const key_type& x) const {
|
||||
return t.upper_bound(x);
|
||||
iterator upper_bound(const key_type& __x) const {
|
||||
return _M_t.upper_bound(__x);
|
||||
}
|
||||
pair<iterator,iterator> equal_range(const key_type& x) const {
|
||||
return t.equal_range(x);
|
||||
pair<iterator,iterator> equal_range(const key_type& __x) const {
|
||||
return _M_t.equal_range(__x);
|
||||
}
|
||||
friend bool operator== __STL_NULL_TMPL_ARGS (const set&, const set&);
|
||||
friend bool operator< __STL_NULL_TMPL_ARGS (const set&, const set&);
|
||||
};
|
||||
|
||||
template <class Key, class Compare, class Alloc>
|
||||
inline bool operator==(const set<Key, Compare, Alloc>& x,
|
||||
const set<Key, Compare, Alloc>& y) {
|
||||
return x.t == y.t;
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline bool operator==(const set<_Key,_Compare,_Alloc>& __x,
|
||||
const set<_Key,_Compare,_Alloc>& __y) {
|
||||
return __x._M_t == __y._M_t;
|
||||
}
|
||||
|
||||
template <class Key, class Compare, class Alloc>
|
||||
inline bool operator<(const set<Key, Compare, Alloc>& x,
|
||||
const set<Key, Compare, Alloc>& y) {
|
||||
return x.t < y.t;
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline bool operator<(const set<_Key,_Compare,_Alloc>& __x,
|
||||
const set<_Key,_Compare,_Alloc>& __y) {
|
||||
return __x._M_t < __y._M_t;
|
||||
}
|
||||
|
||||
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
|
||||
template <class Key, class Compare, class Alloc>
|
||||
inline void swap(set<Key, Compare, Alloc>& x,
|
||||
set<Key, Compare, Alloc>& y) {
|
||||
x.swap(y);
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline void swap(set<_Key,_Compare,_Alloc>& __x,
|
||||
set<_Key,_Compare,_Alloc>& __y) {
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
||||
#pragma reset woff 1174
|
||||
#pragma reset woff 1375
|
||||
#endif
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -34,39 +34,74 @@
|
||||
__STL_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
|
||||
template <class T, class Sequence = deque<T> >
|
||||
template <class _Tp, class _Sequence = deque<_Tp> >
|
||||
#else
|
||||
template <class T, class Sequence>
|
||||
template <class _Tp, class _Sequence>
|
||||
#endif
|
||||
class stack {
|
||||
friend bool operator== __STL_NULL_TMPL_ARGS (const stack&, const stack&);
|
||||
friend bool operator< __STL_NULL_TMPL_ARGS (const stack&, const stack&);
|
||||
public:
|
||||
typedef typename Sequence::value_type value_type;
|
||||
typedef typename Sequence::size_type size_type;
|
||||
typedef typename Sequence::reference reference;
|
||||
typedef typename Sequence::const_reference const_reference;
|
||||
typedef typename _Sequence::value_type value_type;
|
||||
typedef typename _Sequence::size_type size_type;
|
||||
typedef _Sequence container_type;
|
||||
|
||||
typedef typename _Sequence::reference reference;
|
||||
typedef typename _Sequence::const_reference const_reference;
|
||||
protected:
|
||||
Sequence c;
|
||||
_Sequence _M_c;
|
||||
public:
|
||||
bool empty() const { return c.empty(); }
|
||||
size_type size() const { return c.size(); }
|
||||
reference top() { return c.back(); }
|
||||
const_reference top() const { return c.back(); }
|
||||
void push(const value_type& x) { c.push_back(x); }
|
||||
void pop() { c.pop_back(); }
|
||||
stack() : _M_c() {}
|
||||
explicit stack(const _Sequence& __s) : _M_c(__s) {}
|
||||
|
||||
bool empty() const { return _M_c.empty(); }
|
||||
size_type size() const { return _M_c.size(); }
|
||||
reference top() { return _M_c.back(); }
|
||||
const_reference top() const { return _M_c.back(); }
|
||||
void push(const value_type& __x) { _M_c.push_back(__x); }
|
||||
void pop() { _M_c.pop_back(); }
|
||||
};
|
||||
|
||||
template <class T, class Sequence>
|
||||
bool operator==(const stack<T, Sequence>& x, const stack<T, Sequence>& y) {
|
||||
return x.c == y.c;
|
||||
template <class _Tp, class _Seq>
|
||||
bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
|
||||
{
|
||||
return __x._M_c == __y._M_c;
|
||||
}
|
||||
|
||||
template <class T, class Sequence>
|
||||
bool operator<(const stack<T, Sequence>& x, const stack<T, Sequence>& y) {
|
||||
return x.c < y.c;
|
||||
template <class _Tp, class _Seq>
|
||||
bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
|
||||
{
|
||||
return __x._M_c < __y._M_c;
|
||||
}
|
||||
|
||||
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
|
||||
template <class _Tp, class _Seq>
|
||||
bool operator!=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
|
||||
{
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Seq>
|
||||
bool operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
|
||||
{
|
||||
return __y < __x;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Seq>
|
||||
bool operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
|
||||
{
|
||||
return !(__y < __x);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Seq>
|
||||
bool operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
|
||||
{
|
||||
return !(__x < __y);
|
||||
}
|
||||
|
||||
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
||||
#endif /* __SGI_STL_INTERNAL_STACK_H */
|
||||
|
@ -34,86 +34,119 @@
|
||||
|
||||
__STL_BEGIN_NAMESPACE
|
||||
|
||||
template <class T>
|
||||
pair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t len, T*) {
|
||||
if (len > ptrdiff_t(INT_MAX / sizeof(T)))
|
||||
len = INT_MAX / sizeof(T);
|
||||
template <class _Tp>
|
||||
pair<_Tp*, ptrdiff_t>
|
||||
__get_temporary_buffer(ptrdiff_t __len, _Tp*)
|
||||
{
|
||||
if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp)))
|
||||
__len = INT_MAX / sizeof(_Tp);
|
||||
|
||||
while (len > 0) {
|
||||
T* tmp = (T*) malloc((size_t)len * sizeof(T));
|
||||
if (tmp != 0)
|
||||
return pair<T*, ptrdiff_t>(tmp, len);
|
||||
len /= 2;
|
||||
while (__len > 0) {
|
||||
_Tp* __tmp = (_Tp*) malloc((size_t)__len * sizeof(_Tp));
|
||||
if (__tmp != 0)
|
||||
return pair<_Tp*, ptrdiff_t>(__tmp, __len);
|
||||
__len /= 2;
|
||||
}
|
||||
|
||||
return pair<T*, ptrdiff_t>((T*)0, 0);
|
||||
return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void return_temporary_buffer(T* p) {
|
||||
free(p);
|
||||
#ifdef __STL_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
|
||||
template <class _Tp>
|
||||
inline pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len) {
|
||||
return __get_temporary_buffer(__len, (_Tp*) 0);
|
||||
}
|
||||
|
||||
template <class ForwardIterator,
|
||||
class T
|
||||
#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
|
||||
= iterator_traits<ForwardIterator>::value_type
|
||||
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
|
||||
>
|
||||
class temporary_buffer {
|
||||
#endif /* __STL_EXPLICIT_FUNCTION_TMPL_ARGS */
|
||||
|
||||
// This overload is not required by the standard; it is an extension.
|
||||
// It is supported for backward compatibility with the HP STL, and
|
||||
// because not all compilers support the language feature (explicit
|
||||
// function template arguments) that is required for the standard
|
||||
// version of get_temporary_buffer.
|
||||
template <class _Tp>
|
||||
inline pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len, _Tp*) {
|
||||
return __get_temporary_buffer(__len, (_Tp*) 0);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
void return_temporary_buffer(_Tp* __p) {
|
||||
free(__p);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
class _Temporary_buffer {
|
||||
private:
|
||||
ptrdiff_t original_len;
|
||||
ptrdiff_t len;
|
||||
T* buffer;
|
||||
ptrdiff_t _M_original_len;
|
||||
ptrdiff_t _M_len;
|
||||
_Tp* _M_buffer;
|
||||
|
||||
void allocate_buffer() {
|
||||
original_len = len;
|
||||
buffer = 0;
|
||||
void _M_allocate_buffer() {
|
||||
_M_original_len = _M_len;
|
||||
_M_buffer = 0;
|
||||
|
||||
if (len > (ptrdiff_t)(INT_MAX / sizeof(T)))
|
||||
len = INT_MAX / sizeof(T);
|
||||
if (_M_len > (ptrdiff_t)(INT_MAX / sizeof(_Tp)))
|
||||
_M_len = INT_MAX / sizeof(_Tp);
|
||||
|
||||
while (len > 0) {
|
||||
buffer = (T*) malloc(len * sizeof(T));
|
||||
if (buffer)
|
||||
while (_M_len > 0) {
|
||||
_M_buffer = (_Tp*) malloc(_M_len * sizeof(_Tp));
|
||||
if (_M_buffer)
|
||||
break;
|
||||
len /= 2;
|
||||
_M_len /= 2;
|
||||
}
|
||||
}
|
||||
|
||||
void initialize_buffer(const T&, __true_type) {}
|
||||
void initialize_buffer(const T& val, __false_type) {
|
||||
uninitialized_fill_n(buffer, len, val);
|
||||
void _M_initialize_buffer(const _Tp&, __true_type) {}
|
||||
void _M_initialize_buffer(const _Tp& val, __false_type) {
|
||||
uninitialized_fill_n(_M_buffer, _M_len, val);
|
||||
}
|
||||
|
||||
public:
|
||||
ptrdiff_t size() const { return len; }
|
||||
ptrdiff_t requested_size() const { return original_len; }
|
||||
T* begin() { return buffer; }
|
||||
T* end() { return buffer + len; }
|
||||
ptrdiff_t size() const { return _M_len; }
|
||||
ptrdiff_t requested_size() const { return _M_original_len; }
|
||||
_Tp* begin() { return _M_buffer; }
|
||||
_Tp* end() { return _M_buffer + _M_len; }
|
||||
|
||||
temporary_buffer(ForwardIterator first, ForwardIterator last) {
|
||||
_Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) {
|
||||
typedef typename __type_traits<_Tp>::has_trivial_default_constructor
|
||||
_Trivial;
|
||||
__STL_TRY {
|
||||
len = 0;
|
||||
distance(first, last, len);
|
||||
allocate_buffer();
|
||||
if (len > 0)
|
||||
initialize_buffer(*first,
|
||||
typename __type_traits<T>::has_trivial_default_constructor());
|
||||
_M_len = 0;
|
||||
distance(__first, __last, _M_len);
|
||||
_M_allocate_buffer();
|
||||
if (_M_len > 0)
|
||||
_M_initialize_buffer(*__first, _Trivial());
|
||||
}
|
||||
__STL_UNWIND(free(buffer); buffer = 0; len = 0);
|
||||
__STL_UNWIND(free(_M_buffer); _M_buffer = 0; _M_len = 0);
|
||||
}
|
||||
|
||||
~temporary_buffer() {
|
||||
destroy(buffer, buffer + len);
|
||||
free(buffer);
|
||||
~_Temporary_buffer() {
|
||||
destroy(_M_buffer, _M_buffer + _M_len);
|
||||
free(_M_buffer);
|
||||
}
|
||||
|
||||
private:
|
||||
temporary_buffer(const temporary_buffer&) {}
|
||||
void operator=(const temporary_buffer&) {}
|
||||
// Disable copy constructor and assignment operator.
|
||||
_Temporary_buffer(const _Temporary_buffer&) {}
|
||||
void operator=(const _Temporary_buffer&) {}
|
||||
};
|
||||
|
||||
// Class temporary_buffer is not part of the standard. It is an extension.
|
||||
|
||||
template <class _ForwardIterator,
|
||||
class _Tp
|
||||
#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
|
||||
= typename iterator_traits<_ForwardIterator>::value_type
|
||||
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
|
||||
>
|
||||
struct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp>
|
||||
{
|
||||
temporary_buffer(_ForwardIterator __first, _ForwardIterator __last)
|
||||
: _Temporary_buffer<_ForwardIterator, _Tp>(__first, __last) {}
|
||||
~temporary_buffer() {}
|
||||
};
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
||||
#endif /* __SGI_STL_INTERNAL_TEMPBUF_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -33,204 +33,241 @@
|
||||
|
||||
__STL_BEGIN_NAMESPACE
|
||||
|
||||
// uninitialized_copy
|
||||
|
||||
// Valid if copy construction is equivalent to assignment, and if the
|
||||
// destructor is trivial.
|
||||
template <class InputIterator, class ForwardIterator>
|
||||
inline ForwardIterator
|
||||
__uninitialized_copy_aux(InputIterator first, InputIterator last,
|
||||
ForwardIterator result,
|
||||
__true_type) {
|
||||
return copy(first, last, result);
|
||||
template <class _InputIter, class _ForwardIter>
|
||||
inline _ForwardIter
|
||||
__uninitialized_copy_aux(_InputIter __first, _InputIter __last,
|
||||
_ForwardIter __result,
|
||||
__true_type)
|
||||
{
|
||||
return copy(__first, __last, __result);
|
||||
}
|
||||
|
||||
template <class InputIterator, class ForwardIterator>
|
||||
ForwardIterator
|
||||
__uninitialized_copy_aux(InputIterator first, InputIterator last,
|
||||
ForwardIterator result,
|
||||
__false_type) {
|
||||
ForwardIterator cur = result;
|
||||
template <class _InputIter, class _ForwardIter>
|
||||
_ForwardIter
|
||||
__uninitialized_copy_aux(_InputIter __first, _InputIter __last,
|
||||
_ForwardIter __result,
|
||||
__false_type)
|
||||
{
|
||||
_ForwardIter __cur = __result;
|
||||
__STL_TRY {
|
||||
for ( ; first != last; ++first, ++cur)
|
||||
construct(&*cur, *first);
|
||||
return cur;
|
||||
for ( ; __first != __last; ++__first, ++__cur)
|
||||
construct(&*__cur, *__first);
|
||||
return __cur;
|
||||
}
|
||||
__STL_UNWIND(destroy(result, cur));
|
||||
__STL_UNWIND(destroy(__result, __cur));
|
||||
}
|
||||
|
||||
|
||||
template <class InputIterator, class ForwardIterator, class T>
|
||||
inline ForwardIterator
|
||||
__uninitialized_copy(InputIterator first, InputIterator last,
|
||||
ForwardIterator result, T*) {
|
||||
typedef typename __type_traits<T>::is_POD_type is_POD;
|
||||
return __uninitialized_copy_aux(first, last, result, is_POD());
|
||||
template <class _InputIter, class _ForwardIter, class _Tp>
|
||||
inline _ForwardIter
|
||||
__uninitialized_copy(_InputIter __first, _InputIter __last,
|
||||
_ForwardIter __result, _Tp*)
|
||||
{
|
||||
typedef typename __type_traits<_Tp>::is_POD_type _Is_POD;
|
||||
return __uninitialized_copy_aux(__first, __last, __result, _Is_POD());
|
||||
}
|
||||
|
||||
template <class InputIterator, class ForwardIterator>
|
||||
inline ForwardIterator
|
||||
uninitialized_copy(InputIterator first, InputIterator last,
|
||||
ForwardIterator result) {
|
||||
return __uninitialized_copy(first, last, result, value_type(result));
|
||||
template <class _InputIter, class _ForwardIter>
|
||||
inline _ForwardIter
|
||||
uninitialized_copy(_InputIter __first, _InputIter __last,
|
||||
_ForwardIter __result)
|
||||
{
|
||||
return __uninitialized_copy(__first, __last, __result,
|
||||
__VALUE_TYPE(__result));
|
||||
}
|
||||
|
||||
inline char* uninitialized_copy(const char* first, const char* last,
|
||||
char* result) {
|
||||
memmove(result, first, last - first);
|
||||
return result + (last - first);
|
||||
inline char* uninitialized_copy(const char* __first, const char* __last,
|
||||
char* __result) {
|
||||
memmove(__result, __first, __last - __first);
|
||||
return __result + (__last - __first);
|
||||
}
|
||||
|
||||
inline wchar_t* uninitialized_copy(const wchar_t* first, const wchar_t* last,
|
||||
wchar_t* result) {
|
||||
memmove(result, first, sizeof(wchar_t) * (last - first));
|
||||
return result + (last - first);
|
||||
inline wchar_t*
|
||||
uninitialized_copy(const wchar_t* __first, const wchar_t* __last,
|
||||
wchar_t* __result)
|
||||
{
|
||||
memmove(__result, __first, sizeof(wchar_t) * (__last - __first));
|
||||
return __result + (__last - __first);
|
||||
}
|
||||
|
||||
template <class InputIterator, class Size, class ForwardIterator>
|
||||
pair<InputIterator, ForwardIterator>
|
||||
__uninitialized_copy_n(InputIterator first, Size count,
|
||||
ForwardIterator result,
|
||||
input_iterator_tag) {
|
||||
ForwardIterator cur = result;
|
||||
// uninitialized_copy_n (not part of the C++ standard)
|
||||
|
||||
template <class _InputIter, class _Size, class _ForwardIter>
|
||||
pair<_InputIter, _ForwardIter>
|
||||
__uninitialized_copy_n(_InputIter __first, _Size __count,
|
||||
_ForwardIter __result,
|
||||
input_iterator_tag)
|
||||
{
|
||||
_ForwardIter __cur = __result;
|
||||
__STL_TRY {
|
||||
for ( ; count > 0 ; --count, ++first, ++cur)
|
||||
construct(&*cur, *first);
|
||||
return pair<InputIterator, ForwardIterator>(first, cur);
|
||||
for ( ; __count > 0 ; --__count, ++__first, ++__cur)
|
||||
construct(&*__cur, *__first);
|
||||
return pair<_InputIter, _ForwardIter>(__first, __cur);
|
||||
}
|
||||
__STL_UNWIND(destroy(result, cur));
|
||||
__STL_UNWIND(destroy(__result, __cur));
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator, class Size, class ForwardIterator>
|
||||
inline pair<RandomAccessIterator, ForwardIterator>
|
||||
__uninitialized_copy_n(RandomAccessIterator first, Size count,
|
||||
ForwardIterator result,
|
||||
template <class _RandomAccessIter, class _Size, class _ForwardIter>
|
||||
inline pair<_RandomAccessIter, _ForwardIter>
|
||||
__uninitialized_copy_n(_RandomAccessIter __first, _Size __count,
|
||||
_ForwardIter __result,
|
||||
random_access_iterator_tag) {
|
||||
RandomAccessIterator last = first + count;
|
||||
return make_pair(last, uninitialized_copy(first, last, result));
|
||||
_RandomAccessIter __last = __first + __count;
|
||||
return pair<_RandomAccessIter, _ForwardIter>(
|
||||
__last,
|
||||
uninitialized_copy(__first, __last, __result));
|
||||
}
|
||||
|
||||
template <class InputIterator, class Size, class ForwardIterator>
|
||||
inline pair<InputIterator, ForwardIterator>
|
||||
uninitialized_copy_n(InputIterator first, Size count,
|
||||
ForwardIterator result) {
|
||||
return __uninitialized_copy_n(first, count, result,
|
||||
iterator_category(first));
|
||||
template <class _InputIter, class _Size, class _ForwardIter>
|
||||
inline pair<_InputIter, _ForwardIter>
|
||||
__uninitialized_copy_n(_InputIter __first, _Size __count,
|
||||
_ForwardIter __result) {
|
||||
return __uninitialized_copy_n(__first, __count, __result,
|
||||
__ITERATOR_CATEGORY(__first));
|
||||
}
|
||||
|
||||
template <class _InputIter, class _Size, class _ForwardIter>
|
||||
inline pair<_InputIter, _ForwardIter>
|
||||
uninitialized_copy_n(_InputIter __first, _Size __count,
|
||||
_ForwardIter __result) {
|
||||
return __uninitialized_copy_n(__first, __count, __result,
|
||||
__ITERATOR_CATEGORY(__first));
|
||||
}
|
||||
|
||||
// Valid if copy construction is equivalent to assignment, and if the
|
||||
// destructor is trivial.
|
||||
template <class ForwardIterator, class T>
|
||||
// destructor is trivial.
|
||||
template <class _ForwardIter, class _Tp>
|
||||
inline void
|
||||
__uninitialized_fill_aux(ForwardIterator first, ForwardIterator last,
|
||||
const T& x, __true_type)
|
||||
__uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last,
|
||||
const _Tp& __x, __true_type)
|
||||
{
|
||||
fill(first, last, x);
|
||||
fill(__first, __last, __x);
|
||||
}
|
||||
|
||||
template <class ForwardIterator, class T>
|
||||
template <class _ForwardIter, class _Tp>
|
||||
void
|
||||
__uninitialized_fill_aux(ForwardIterator first, ForwardIterator last,
|
||||
const T& x, __false_type)
|
||||
__uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last,
|
||||
const _Tp& __x, __false_type)
|
||||
{
|
||||
ForwardIterator cur = first;
|
||||
_ForwardIter __cur = __first;
|
||||
__STL_TRY {
|
||||
for ( ; cur != last; ++cur)
|
||||
construct(&*cur, x);
|
||||
for ( ; __cur != __last; ++__cur)
|
||||
construct(&*__cur, __x);
|
||||
}
|
||||
__STL_UNWIND(destroy(first, cur));
|
||||
__STL_UNWIND(destroy(__first, __cur));
|
||||
}
|
||||
|
||||
template <class ForwardIterator, class T, class T1>
|
||||
inline void __uninitialized_fill(ForwardIterator first, ForwardIterator last,
|
||||
const T& x, T1*) {
|
||||
typedef typename __type_traits<T1>::is_POD_type is_POD;
|
||||
__uninitialized_fill_aux(first, last, x, is_POD());
|
||||
template <class _ForwardIter, class _Tp, class _Tp1>
|
||||
inline void __uninitialized_fill(_ForwardIter __first,
|
||||
_ForwardIter __last, const _Tp& __x, _Tp1*)
|
||||
{
|
||||
typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD;
|
||||
__uninitialized_fill_aux(__first, __last, __x, _Is_POD());
|
||||
|
||||
}
|
||||
|
||||
template <class ForwardIterator, class T>
|
||||
inline void uninitialized_fill(ForwardIterator first, ForwardIterator last,
|
||||
const T& x) {
|
||||
__uninitialized_fill(first, last, x, value_type(first));
|
||||
template <class _ForwardIter, class _Tp>
|
||||
inline void uninitialized_fill(_ForwardIter __first,
|
||||
_ForwardIter __last,
|
||||
const _Tp& __x)
|
||||
{
|
||||
__uninitialized_fill(__first, __last, __x, __VALUE_TYPE(__first));
|
||||
}
|
||||
|
||||
// Valid if copy construction is equivalent to assignment, and if the
|
||||
// destructor is trivial.
|
||||
template <class ForwardIterator, class Size, class T>
|
||||
inline ForwardIterator
|
||||
__uninitialized_fill_n_aux(ForwardIterator first, Size n,
|
||||
const T& x, __true_type) {
|
||||
return fill_n(first, n, x);
|
||||
template <class _ForwardIter, class _Size, class _Tp>
|
||||
inline _ForwardIter
|
||||
__uninitialized_fill_n_aux(_ForwardIter __first, _Size __n,
|
||||
const _Tp& __x, __true_type)
|
||||
{
|
||||
return fill_n(__first, __n, __x);
|
||||
}
|
||||
|
||||
template <class ForwardIterator, class Size, class T>
|
||||
ForwardIterator
|
||||
__uninitialized_fill_n_aux(ForwardIterator first, Size n,
|
||||
const T& x, __false_type) {
|
||||
ForwardIterator cur = first;
|
||||
template <class _ForwardIter, class _Size, class _Tp>
|
||||
_ForwardIter
|
||||
__uninitialized_fill_n_aux(_ForwardIter __first, _Size __n,
|
||||
const _Tp& __x, __false_type)
|
||||
{
|
||||
_ForwardIter __cur = __first;
|
||||
__STL_TRY {
|
||||
for ( ; n > 0; --n, ++cur)
|
||||
construct(&*cur, x);
|
||||
return cur;
|
||||
for ( ; __n > 0; --__n, ++__cur)
|
||||
construct(&*__cur, __x);
|
||||
return __cur;
|
||||
}
|
||||
__STL_UNWIND(destroy(first, cur));
|
||||
__STL_UNWIND(destroy(__first, __cur));
|
||||
}
|
||||
|
||||
template <class ForwardIterator, class Size, class T, class T1>
|
||||
inline ForwardIterator __uninitialized_fill_n(ForwardIterator first, Size n,
|
||||
const T& x, T1*) {
|
||||
typedef typename __type_traits<T1>::is_POD_type is_POD;
|
||||
return __uninitialized_fill_n_aux(first, n, x, is_POD());
|
||||
|
||||
template <class _ForwardIter, class _Size, class _Tp, class _Tp1>
|
||||
inline _ForwardIter
|
||||
__uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x, _Tp1*)
|
||||
{
|
||||
typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD;
|
||||
return __uninitialized_fill_n_aux(__first, __n, __x, _Is_POD());
|
||||
}
|
||||
|
||||
template <class ForwardIterator, class Size, class T>
|
||||
inline ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n,
|
||||
const T& x) {
|
||||
return __uninitialized_fill_n(first, n, x, value_type(first));
|
||||
template <class _ForwardIter, class _Size, class _Tp>
|
||||
inline _ForwardIter
|
||||
uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x)
|
||||
{
|
||||
return __uninitialized_fill_n(__first, __n, __x, __VALUE_TYPE(__first));
|
||||
}
|
||||
|
||||
// Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill,
|
||||
// __uninitialized_fill_copy.
|
||||
|
||||
// __uninitialized_copy_copy
|
||||
// Copies [first1, last1) into [result, result + (last1 - first1)), and
|
||||
// copies [first2, last2) into
|
||||
// [result, result + (last1 - first1) + (last2 - first2)).
|
||||
|
||||
template <class InputIterator1, class InputIterator2, class ForwardIterator>
|
||||
inline ForwardIterator
|
||||
__uninitialized_copy_copy(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2,
|
||||
ForwardIterator result) {
|
||||
ForwardIterator mid = uninitialized_copy(first1, last1, result);
|
||||
template <class _InputIter1, class _InputIter2, class _ForwardIter>
|
||||
inline _ForwardIter
|
||||
__uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_ForwardIter __result)
|
||||
{
|
||||
_ForwardIter __mid = uninitialized_copy(__first1, __last1, __result);
|
||||
__STL_TRY {
|
||||
return uninitialized_copy(first2, last2, mid);
|
||||
return uninitialized_copy(__first2, __last2, __mid);
|
||||
}
|
||||
__STL_UNWIND(destroy(result, mid));
|
||||
__STL_UNWIND(destroy(__result, __mid));
|
||||
}
|
||||
|
||||
// __uninitialized_fill_copy
|
||||
// Fills [result, mid) with x, and copies [first, last) into
|
||||
// [mid, mid + (last - first)).
|
||||
template <class ForwardIterator, class T, class InputIterator>
|
||||
inline ForwardIterator
|
||||
__uninitialized_fill_copy(ForwardIterator result, ForwardIterator mid,
|
||||
const T& x,
|
||||
InputIterator first, InputIterator last) {
|
||||
uninitialized_fill(result, mid, x);
|
||||
template <class _ForwardIter, class _Tp, class _InputIter>
|
||||
inline _ForwardIter
|
||||
__uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid,
|
||||
const _Tp& __x,
|
||||
_InputIter __first, _InputIter __last)
|
||||
{
|
||||
uninitialized_fill(__result, __mid, __x);
|
||||
__STL_TRY {
|
||||
return uninitialized_copy(first, last, mid);
|
||||
return uninitialized_copy(__first, __last, __mid);
|
||||
}
|
||||
__STL_UNWIND(destroy(result, mid));
|
||||
__STL_UNWIND(destroy(__result, __mid));
|
||||
}
|
||||
|
||||
// __uninitialized_copy_fill
|
||||
// Copies [first1, last1) into [first2, first2 + (last1 - first1)), and
|
||||
// fills [first2 + (last1 - first1), last2) with x.
|
||||
template <class InputIterator, class ForwardIterator, class T>
|
||||
template <class _InputIter, class _ForwardIter, class _Tp>
|
||||
inline void
|
||||
__uninitialized_copy_fill(InputIterator first1, InputIterator last1,
|
||||
ForwardIterator first2, ForwardIterator last2,
|
||||
const T& x) {
|
||||
ForwardIterator mid2 = uninitialized_copy(first1, last1, first2);
|
||||
__uninitialized_copy_fill(_InputIter __first1, _InputIter __last1,
|
||||
_ForwardIter __first2, _ForwardIter __last2,
|
||||
const _Tp& __x)
|
||||
{
|
||||
_ForwardIter __mid2 = uninitialized_copy(__first1, __last1, __first2);
|
||||
__STL_TRY {
|
||||
uninitialized_fill(mid2, last2, x);
|
||||
uninitialized_fill(__mid2, __last2, __x);
|
||||
}
|
||||
__STL_UNWIND(destroy(first2, mid2));
|
||||
__STL_UNWIND(destroy(__first2, __mid2));
|
||||
}
|
||||
|
||||
__STL_END_NAMESPACE
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -30,15 +30,18 @@
|
||||
#ifndef __SGI_STL_PAIR_H
|
||||
#include <pair.h>
|
||||
#endif
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h> /* XXX should use <climits> */
|
||||
#include <stddef.h> /* XXX should use <cstddef> */
|
||||
#include <stdlib.h> /* XXX should use <cstdlib> */
|
||||
#ifndef __TYPE_TRAITS_H
|
||||
#include <type_traits.h>
|
||||
#endif
|
||||
#ifndef __SGI_STL_INTERNAL_CONSTRUCT_H
|
||||
#include <stl_construct.h>
|
||||
#endif
|
||||
#ifndef __SGI_STL_INTERNAL_UNINITIALIZED_H
|
||||
#include <stl_uninitialized.h>
|
||||
#endif
|
||||
#ifndef __SGI_STL_INTERNAL_TEMPBUF_H
|
||||
#include <stl_tempbuf.h>
|
||||
#endif
|
||||
|
@ -40,13 +40,14 @@ attain their correct values by one of these means:
|
||||
EXAMPLE:
|
||||
|
||||
//Copy an array of elements which have non-trivial copy constructors
|
||||
template <class T> void copy(T* source,T* destination,int n,__false_type);
|
||||
template <class T> void copy(T* source, T* destination, int n, __false_type);
|
||||
//Copy an array of elements which have trivial copy constructors. Use memcpy.
|
||||
template <class T> void copy(T* source,T* destination,int n,__true_type);
|
||||
template <class T> void copy(T* source, T* destination, int n, __true_type);
|
||||
|
||||
//Copy an array of any type by using the most efficient copy mechanism
|
||||
template <class T> inline void copy(T* source,T* destination,int n) {
|
||||
copy(source,destination,n,typename __type_traits<T>::has_trivial_copy_constructor());
|
||||
copy(source, destination, n,
|
||||
typename __type_traits<T>::has_trivial_copy_constructor());
|
||||
}
|
||||
*/
|
||||
|
||||
@ -57,7 +58,7 @@ struct __true_type {
|
||||
struct __false_type {
|
||||
};
|
||||
|
||||
template <class type>
|
||||
template <class _Tp>
|
||||
struct __type_traits {
|
||||
typedef __true_type this_dummy_member_must_be_first;
|
||||
/* Do not remove this member. It informs a compiler which
|
||||
@ -90,6 +91,18 @@ struct __type_traits {
|
||||
// have built-in __types_traits support, and essential for compilers
|
||||
// that don't.
|
||||
|
||||
#ifndef __STL_NO_BOOL
|
||||
|
||||
__STL_TEMPLATE_NULL struct __type_traits<bool> {
|
||||
typedef __true_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __true_type has_trivial_assignment_operator;
|
||||
typedef __true_type has_trivial_destructor;
|
||||
typedef __true_type is_POD_type;
|
||||
};
|
||||
|
||||
#endif /* __STL_NO_BOOL */
|
||||
|
||||
__STL_TEMPLATE_NULL struct __type_traits<char> {
|
||||
typedef __true_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
@ -114,6 +127,18 @@ __STL_TEMPLATE_NULL struct __type_traits<unsigned char> {
|
||||
typedef __true_type is_POD_type;
|
||||
};
|
||||
|
||||
#ifdef __STL_HAS_WCHAR_T
|
||||
|
||||
__STL_TEMPLATE_NULL struct __type_traits<wchar_t> {
|
||||
typedef __true_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __true_type has_trivial_assignment_operator;
|
||||
typedef __true_type has_trivial_destructor;
|
||||
typedef __true_type is_POD_type;
|
||||
};
|
||||
|
||||
#endif /* __STL_HAS_WCHAR_T */
|
||||
|
||||
__STL_TEMPLATE_NULL struct __type_traits<short> {
|
||||
typedef __true_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
@ -162,6 +187,26 @@ __STL_TEMPLATE_NULL struct __type_traits<unsigned long> {
|
||||
typedef __true_type is_POD_type;
|
||||
};
|
||||
|
||||
#ifdef __STL_LONG_LONG
|
||||
|
||||
__STL_TEMPLATE_NULL struct __type_traits<long long> {
|
||||
typedef __true_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __true_type has_trivial_assignment_operator;
|
||||
typedef __true_type has_trivial_destructor;
|
||||
typedef __true_type is_POD_type;
|
||||
};
|
||||
|
||||
__STL_TEMPLATE_NULL struct __type_traits<unsigned long long> {
|
||||
typedef __true_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __true_type has_trivial_assignment_operator;
|
||||
typedef __true_type has_trivial_destructor;
|
||||
typedef __true_type is_POD_type;
|
||||
};
|
||||
|
||||
#endif /* __STL_LONG_LONG */
|
||||
|
||||
__STL_TEMPLATE_NULL struct __type_traits<float> {
|
||||
typedef __true_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
@ -188,8 +233,8 @@ __STL_TEMPLATE_NULL struct __type_traits<long double> {
|
||||
|
||||
#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
|
||||
|
||||
template <class T>
|
||||
struct __type_traits<T*> {
|
||||
template <class _Tp>
|
||||
struct __type_traits<_Tp*> {
|
||||
typedef __true_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __true_type has_trivial_assignment_operator;
|
||||
@ -199,7 +244,7 @@ struct __type_traits<T*> {
|
||||
|
||||
#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */
|
||||
|
||||
struct __type_traits<char*> {
|
||||
__STL_TEMPLATE_NULL struct __type_traits<char*> {
|
||||
typedef __true_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __true_type has_trivial_assignment_operator;
|
||||
@ -207,7 +252,7 @@ struct __type_traits<char*> {
|
||||
typedef __true_type is_POD_type;
|
||||
};
|
||||
|
||||
struct __type_traits<signed char*> {
|
||||
__STL_TEMPLATE_NULL struct __type_traits<signed char*> {
|
||||
typedef __true_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __true_type has_trivial_assignment_operator;
|
||||
@ -215,7 +260,31 @@ struct __type_traits<signed char*> {
|
||||
typedef __true_type is_POD_type;
|
||||
};
|
||||
|
||||
struct __type_traits<unsigned char*> {
|
||||
__STL_TEMPLATE_NULL struct __type_traits<unsigned char*> {
|
||||
typedef __true_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __true_type has_trivial_assignment_operator;
|
||||
typedef __true_type has_trivial_destructor;
|
||||
typedef __true_type is_POD_type;
|
||||
};
|
||||
|
||||
__STL_TEMPLATE_NULL struct __type_traits<const char*> {
|
||||
typedef __true_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __true_type has_trivial_assignment_operator;
|
||||
typedef __true_type has_trivial_destructor;
|
||||
typedef __true_type is_POD_type;
|
||||
};
|
||||
|
||||
__STL_TEMPLATE_NULL struct __type_traits<const signed char*> {
|
||||
typedef __true_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __true_type has_trivial_assignment_operator;
|
||||
typedef __true_type has_trivial_destructor;
|
||||
typedef __true_type is_POD_type;
|
||||
};
|
||||
|
||||
__STL_TEMPLATE_NULL struct __type_traits<const unsigned char*> {
|
||||
typedef __true_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __true_type has_trivial_assignment_operator;
|
||||
@ -226,6 +295,77 @@ struct __type_traits<unsigned char*> {
|
||||
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
|
||||
|
||||
|
||||
// The following could be written in terms of numeric_limits.
|
||||
// We're doing it separately to reduce the number of dependencies.
|
||||
|
||||
template <class _Tp> struct _Is_integer {
|
||||
typedef __false_type _Integral;
|
||||
};
|
||||
|
||||
#ifndef __STL_NO_BOOL
|
||||
|
||||
__STL_TEMPLATE_NULL struct _Is_integer<bool> {
|
||||
typedef __true_type _Integral;
|
||||
};
|
||||
|
||||
#endif /* __STL_NO_BOOL */
|
||||
|
||||
__STL_TEMPLATE_NULL struct _Is_integer<char> {
|
||||
typedef __true_type _Integral;
|
||||
};
|
||||
|
||||
__STL_TEMPLATE_NULL struct _Is_integer<signed char> {
|
||||
typedef __true_type _Integral;
|
||||
};
|
||||
|
||||
__STL_TEMPLATE_NULL struct _Is_integer<unsigned char> {
|
||||
typedef __true_type _Integral;
|
||||
};
|
||||
|
||||
#ifdef __STL_HAS_WCHAR_T
|
||||
|
||||
__STL_TEMPLATE_NULL struct _Is_integer<wchar_t> {
|
||||
typedef __true_type _Integral;
|
||||
};
|
||||
|
||||
#endif /* __STL_HAS_WCHAR_T */
|
||||
|
||||
__STL_TEMPLATE_NULL struct _Is_integer<short> {
|
||||
typedef __true_type _Integral;
|
||||
};
|
||||
|
||||
__STL_TEMPLATE_NULL struct _Is_integer<unsigned short> {
|
||||
typedef __true_type _Integral;
|
||||
};
|
||||
|
||||
__STL_TEMPLATE_NULL struct _Is_integer<int> {
|
||||
typedef __true_type _Integral;
|
||||
};
|
||||
|
||||
__STL_TEMPLATE_NULL struct _Is_integer<unsigned int> {
|
||||
typedef __true_type _Integral;
|
||||
};
|
||||
|
||||
__STL_TEMPLATE_NULL struct _Is_integer<long> {
|
||||
typedef __true_type _Integral;
|
||||
};
|
||||
|
||||
__STL_TEMPLATE_NULL struct _Is_integer<unsigned long> {
|
||||
typedef __true_type _Integral;
|
||||
};
|
||||
|
||||
#ifdef __STL_LONG_LONG
|
||||
|
||||
__STL_TEMPLATE_NULL struct _Is_integer<long long> {
|
||||
typedef __true_type _Integral;
|
||||
};
|
||||
|
||||
__STL_TEMPLATE_NULL struct _Is_integer<unsigned long long> {
|
||||
typedef __true_type _Integral;
|
||||
};
|
||||
|
||||
#endif /* __STL_LONG_LONG */
|
||||
|
||||
#endif /* __TYPE_TRAITS_H */
|
||||
|
||||
// Local Variables:
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <alloc.h>
|
||||
|
||||
#ifndef __USE_MALLOC
|
||||
template class __default_alloc_template<__NODE_ALLOCATOR_THREADS, 0>;
|
||||
#endif
|
||||
|
||||
template class __malloc_alloc_template<0>;
|
||||
|
@ -1,6 +1,14 @@
|
||||
Sun Mar 14 02:38:07 PST 1999 Jeff Law (law@cygnus.com)
|
||||
Mon Aug 16 01:29:24 PDT 1999 Jeff Law (law@cygnus.com)
|
||||
|
||||
* egcs-1.1.2 Released.
|
||||
* gcc-2.95.1 Released.
|
||||
|
||||
Wed Jul 28 21:39:31 PDT 1999 Jeff Law (law@cygnus.com)
|
||||
|
||||
* gcc-2.95 Released.
|
||||
|
||||
Sun Jul 25 23:40:51 PDT 1999 Jeff Law (law@cygnus.com)
|
||||
|
||||
* gcc-2.95 Released.
|
||||
|
||||
1998-07-17 Jason Merrill <jason@yorick.cygnus.com>
|
||||
|
||||
|
@ -1,6 +1,18 @@
|
||||
Sun Mar 14 02:38:07 PST 1999 Jeff Law (law@cygnus.com)
|
||||
Mon Aug 16 01:29:24 PDT 1999 Jeff Law (law@cygnus.com)
|
||||
|
||||
* egcs-1.1.2 Released.
|
||||
* gcc-2.95.1 Released.
|
||||
|
||||
Wed Jul 28 21:39:31 PDT 1999 Jeff Law (law@cygnus.com)
|
||||
|
||||
* gcc-2.95 Released.
|
||||
|
||||
Sun Jul 25 23:40:51 PDT 1999 Jeff Law (law@cygnus.com)
|
||||
|
||||
* gcc-2.95 Released.
|
||||
|
||||
Wed Nov 25 01:00:07 1998 Marc Espie <espie@quatramaran.ens.fr>
|
||||
|
||||
* Makefile.in (just-check): Ignore errors.
|
||||
|
||||
Sun Jun 28 00:00:10 1998 Carlo Wood <carlo@runaway.xs4all.nl>
|
||||
|
||||
|
@ -13,7 +13,8 @@
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU CC; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
# the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA. */
|
||||
|
||||
srcdir = libstdc++.tests
|
||||
|
||||
@ -57,7 +58,7 @@ site.exp: ./config.status Makefile
|
||||
-@rm -f ./tmp?
|
||||
|
||||
just-check: site.exp
|
||||
rootme=`pwd`; export rootme; \
|
||||
-rootme=`pwd`; export rootme; \
|
||||
srcdir=${srcdir} ; export srcdir ; \
|
||||
EXPECT=${EXPECT} ; export EXPECT ; \
|
||||
if [ -f $${rootme}/../../expect/expect ] ; then \
|
||||
|
8
contrib/libstdc++/valarray
Normal file
8
contrib/libstdc++/valarray
Normal file
@ -0,0 +1,8 @@
|
||||
// Main header for -*- C++ -*- valarray classes.
|
||||
|
||||
#ifndef __VALARRAY__
|
||||
#define __VALARRAY__
|
||||
|
||||
#include <std/std_valarray.h>
|
||||
|
||||
#endif
|
50
contrib/libstdc++/valarray.cc
Normal file
50
contrib/libstdc++/valarray.cc
Normal file
@ -0,0 +1,50 @@
|
||||
#include <std/std_valarray.h>
|
||||
|
||||
// Some Explicit Instanciations.
|
||||
template class multiplies<size_t>;
|
||||
template size_t accumulate(size_t*, size_t*, size_t, multiplies<size_t>);
|
||||
|
||||
template void
|
||||
__valarray_fill(size_t* __restrict__, size_t, const size_t&);
|
||||
|
||||
template void
|
||||
__valarray_copy(const size_t* __restrict__, size_t, size_t* __restrict__);
|
||||
|
||||
template valarray<size_t>::valarray(size_t);
|
||||
template valarray<size_t>::~valarray();
|
||||
template valarray<size_t>::valarray(const valarray<size_t>&);
|
||||
template size_t valarray<size_t>::size() const;
|
||||
template size_t& valarray<size_t>::operator[](size_t);
|
||||
template size_t valarray<size_t>::product() const;
|
||||
|
||||
|
||||
void __gslice_to_index(size_t __o, const valarray<size_t>& __l,
|
||||
const valarray<size_t>& __s,
|
||||
valarray<size_t>& __i)
|
||||
{
|
||||
const size_t __n = __l.size();
|
||||
size_t* const __t = static_cast<size_t*>(alloca(__n*sizeof(size_t)));
|
||||
__valarray_fill(__t, __n, size_t(0));
|
||||
const size_t __z = __i.size();
|
||||
__valarray_fill(&__i[0], __z, __o);
|
||||
for (size_t __j=0; __j<__z; ++__j) {
|
||||
for (size_t __k=0; __k<__n; ++__k)
|
||||
__i[__j] += __s[__k]*__t[__k];
|
||||
++__t[__n-1];
|
||||
for (size_t __k=__n-1; __k; --__k) {
|
||||
if (__t[__k] >= __l[__k]) {
|
||||
__t[__k] = 0;
|
||||
++__t[__k-1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_Indexer::_Indexer(size_t __o, const valarray<size_t>& __l,
|
||||
const valarray<size_t>& __s)
|
||||
: _M_count(1), _M_start(__o), _M_size(__l), _M_stride(__s),
|
||||
_M_index(__l.size() ? __l.product() : 0)
|
||||
{ __gslice_to_index(__o, __l, __s, _M_index); }
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user