From 087faf9f67a85b7afa89b48535750ed4bf64d2ec Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 20 Mar 2015 13:53:54 +0000 Subject: [PATCH] added QSE_CPP_RVREF. enhanced Array and BinaryHeap for C++11 --- qse/bld/msdos-watcom/makefile | 6 +- qse/bld/os2-watcom/makefile | 12 +++- qse/bld/qse.bkl | 1 + qse/bld/win32-borland/makefile | 12 +++- qse/bld/win32-msvc/makefile | 12 +++- qse/bld/win32-watcom/makefile | 12 +++- qse/include/qse/Exception.hpp | 3 +- qse/include/qse/Growable.hpp | 3 +- qse/include/qse/Hashable.hpp | 3 +- qse/include/qse/Types.hpp | 36 +++++++++++- qse/include/qse/Uncopyable.hpp | 3 +- qse/include/qse/cmn/Array.hpp | 59 ++++++++++++++----- qse/include/qse/cmn/Association.hpp | 3 +- qse/include/qse/cmn/BinaryHeap.hpp | 62 ++++++++++---------- qse/include/qse/cmn/HashList.hpp | 10 +++- qse/include/qse/cmn/LinkedList.hpp | 5 ++ qse/include/qse/cmn/Mmgr.hpp | 2 - qse/include/qse/cmn/StrBase.hpp | 17 +++++- qse/lib/awk/mod-math.c | 2 +- qse/samples/cmn/Makefile.am | 5 +- qse/samples/cmn/Makefile.in | 55 +++++++++++------- qse/samples/cmn/arr01.cpp | 2 +- qse/samples/cmn/arr02.cpp | 18 +++++- qse/samples/cmn/bh02.cpp | 90 +++++++++++++++++++++++++++++ 24 files changed, 333 insertions(+), 100 deletions(-) create mode 100644 qse/samples/cmn/bh02.cpp diff --git a/qse/bld/msdos-watcom/makefile b/qse/bld/msdos-watcom/makefile index 4c5f3d8a..7658a2a8 100644 --- a/qse/bld/msdos-watcom/makefile +++ b/qse/bld/msdos-watcom/makefile @@ -392,7 +392,8 @@ LIBQSECMNXX_OBJECTS = & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-static$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_StdMmgr.obj & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-static$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_HeapMmgr.obj & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-static$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mmged.obj & - $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-static$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-static$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj & + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-static$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_String.obj LIBQSEAWKXX_CXXFLAGS = $(____DOS_CFLAG_p) -i=..\..\include $(CPPFLAGS_BUILD) & $(CPPFLAGS_CHAR) $(CPPFLAGS_XCMGRS) $(CPPFLAGS_BUNDLED_UNICODE) & -DQSE_ENABLE_STATIC_MODULE $(CPPFLAGS_TCPV40HDRS) -wx $(__DEBUG_INFO) -bm -ot & @@ -953,6 +954,9 @@ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-static$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mmge $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-static$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj : .AUTODEPEND ..\..\lib\cmn\Mpool.cpp $(CXX) -bt=dos -zq -fo=$^@ $(LIBQSECMNXX_CXXFLAGS) $< +$(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-static$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_String.obj : .AUTODEPEND ..\..\lib\cmn\String.cpp + $(CXX) -bt=dos -zq -fo=$^@ $(LIBQSECMNXX_CXXFLAGS) $< + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-static$(BUILDDIR_TCPV40HDRS)\libqseawkxx_Awk.obj : .AUTODEPEND ..\..\lib\awk\Awk.cpp $(CXX) -bt=dos -zq -fo=$^@ $(LIBQSEAWKXX_CXXFLAGS) $< diff --git a/qse/bld/os2-watcom/makefile b/qse/bld/os2-watcom/makefile index b309f824..e61b9fdf 100644 --- a/qse/bld/os2-watcom/makefile +++ b/qse/bld/os2-watcom/makefile @@ -672,7 +672,8 @@ DLLQSECMNXX_OBJECTS = & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_StdMmgr.obj & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_HeapMmgr.obj & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mmged.obj & - $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mpool.obj + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mpool.obj & + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_String.obj LIBQSECMNXX_CXXFLAGS = -i=..\..\include $(CPPFLAGS_BUILD) $(CPPFLAGS_CHAR) & $(CPPFLAGS_XCMGRS) $(CPPFLAGS_BUNDLED_UNICODE) $(CPPFLAGS_STATIC_MODULE) & $(CPPFLAGS_TCPV40HDRS) -wx $(__DEBUG_INFO) -bm -ot -ox -xs $(CPPFLAGS) & @@ -682,7 +683,8 @@ LIBQSECMNXX_OBJECTS = & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_StdMmgr.obj & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_HeapMmgr.obj & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mmged.obj & - $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj & + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_String.obj DLLQSEAWKXX_CXXFLAGS = -bd -i=..\..\include $(CPPFLAGS_BUILD) $(CPPFLAGS_CHAR) & $(CPPFLAGS_XCMGRS) $(CPPFLAGS_BUNDLED_UNICODE) $(CPPFLAGS_STATIC_MODULE) & $(CPPFLAGS_TCPV40HDRS) -wx $(__DEBUG_INFO) -bm -ot -ox -xs $(CPPFLAGS) & @@ -1911,6 +1913,9 @@ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllq $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mpool.obj : .AUTODEPEND ..\..\lib\cmn\Mpool.cpp $(CXX) -bt=os2 -zq -fo=$^@ $(DLLQSECMNXX_CXXFLAGS) $< +$(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_String.obj : .AUTODEPEND ..\..\lib\cmn\String.cpp + $(CXX) -bt=os2 -zq -fo=$^@ $(DLLQSECMNXX_CXXFLAGS) $< + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mmgr.obj : .AUTODEPEND ..\..\lib\cmn\Mmgr.cpp $(CXX) -bt=os2 -zq -fo=$^@ $(LIBQSECMNXX_CXXFLAGS) $< @@ -1926,6 +1931,9 @@ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libq $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj : .AUTODEPEND ..\..\lib\cmn\Mpool.cpp $(CXX) -bt=os2 -zq -fo=$^@ $(LIBQSECMNXX_CXXFLAGS) $< +$(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_String.obj : .AUTODEPEND ..\..\lib\cmn\String.cpp + $(CXX) -bt=os2 -zq -fo=$^@ $(LIBQSECMNXX_CXXFLAGS) $< + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqseawkxx_Awk.obj : .AUTODEPEND ..\..\lib\awk\Awk.cpp $(CXX) -bt=os2 -zq -fo=$^@ $(DLLQSEAWKXX_CXXFLAGS) $< diff --git a/qse/bld/qse.bkl b/qse/bld/qse.bkl index d9adcd45..90a87a2f 100644 --- a/qse/bld/qse.bkl +++ b/qse/bld/qse.bkl @@ -309,6 +309,7 @@ HeapMmgr.cpp Mmged.cpp Mpool.cpp + String.cpp diff --git a/qse/bld/win32-borland/makefile b/qse/bld/win32-borland/makefile index 9a328ecd..c8c60e47 100644 --- a/qse/bld/win32-borland/makefile +++ b/qse/bld/win32-borland/makefile @@ -458,7 +458,8 @@ DLLQSECMNXX_OBJECTS = \ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_StdMmgr.obj \ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_HeapMmgr.obj \ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mmged.obj \ - $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mpool.obj + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mpool.obj \ + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_String.obj LIBQSECMNXX_CXXFLAGS = -I$(BCCDIR)\include -I..\..\include $(CPPFLAGS_BUILD) \ $(CPPFLAGS_CHAR) $(CPPFLAGS_XCMGRS) $(CPPFLAGS_BUNDLED_UNICODE) \ $(CPPFLAGS_STATIC_MODULE) $(CPPFLAGS_TCPV40HDRS) $(__DEBUG_INFO) -tWM -O2 \ @@ -468,7 +469,8 @@ LIBQSECMNXX_OBJECTS = \ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_StdMmgr.obj \ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_HeapMmgr.obj \ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mmged.obj \ - $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj \ + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_String.obj DLLQSEAWKXX_CXXFLAGS = -I$(BCCDIR)\include -I..\..\include $(CPPFLAGS_BUILD) \ $(CPPFLAGS_CHAR) $(CPPFLAGS_XCMGRS) $(CPPFLAGS_BUNDLED_UNICODE) \ $(CPPFLAGS_STATIC_MODULE) $(CPPFLAGS_TCPV40HDRS) $(__DEBUG_INFO) -tWM -O2 \ @@ -1859,6 +1861,9 @@ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllq $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mpool.obj: ..\..\lib\cmn\Mpool.cpp $(CXX) -q -c -P -o$@ $(DLLQSECMNXX_CXXFLAGS) ..\..\lib\cmn\Mpool.cpp +$(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_String.obj: ..\..\lib\cmn\String.cpp + $(CXX) -q -c -P -o$@ $(DLLQSECMNXX_CXXFLAGS) ..\..\lib\cmn\String.cpp + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mmgr.obj: ..\..\lib\cmn\Mmgr.cpp $(CXX) -q -c -P -o$@ $(LIBQSECMNXX_CXXFLAGS) ..\..\lib\cmn\Mmgr.cpp @@ -1874,6 +1879,9 @@ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libq $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj: ..\..\lib\cmn\Mpool.cpp $(CXX) -q -c -P -o$@ $(LIBQSECMNXX_CXXFLAGS) ..\..\lib\cmn\Mpool.cpp +$(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_String.obj: ..\..\lib\cmn\String.cpp + $(CXX) -q -c -P -o$@ $(LIBQSECMNXX_CXXFLAGS) ..\..\lib\cmn\String.cpp + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqseawkxx_Awk.obj: ..\..\lib\awk\Awk.cpp $(CXX) -q -c -P -o$@ $(DLLQSEAWKXX_CXXFLAGS) ..\..\lib\awk\Awk.cpp diff --git a/qse/bld/win32-msvc/makefile b/qse/bld/win32-msvc/makefile index d54458c8..8b2242a5 100644 --- a/qse/bld/win32-msvc/makefile +++ b/qse/bld/win32-msvc/makefile @@ -465,7 +465,8 @@ DLLQSECMNXX_OBJECTS = \ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_StdMmgr.obj \ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_HeapMmgr.obj \ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mmged.obj \ - $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mpool.obj + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mpool.obj \ + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_String.obj LIBQSECMNXX_CXXFLAGS = /MD$(__DEBUG_INFO_28) /DWIN32 /I..\..\include \ $(CPPFLAGS_BUILD) $(CPPFLAGS_CHAR) $(CPPFLAGS_XCMGRS) \ $(CPPFLAGS_BUNDLED_UNICODE) $(CPPFLAGS_STATIC_MODULE) \ @@ -477,7 +478,8 @@ LIBQSECMNXX_OBJECTS = \ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_StdMmgr.obj \ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_HeapMmgr.obj \ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mmged.obj \ - $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj \ + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_String.obj DLLQSEAWKXX_CXXFLAGS = /MD$(__DEBUG_INFO_28) /DWIN32 /I..\..\include \ $(CPPFLAGS_BUILD) $(CPPFLAGS_CHAR) $(CPPFLAGS_XCMGRS) \ $(CPPFLAGS_BUNDLED_UNICODE) $(CPPFLAGS_STATIC_MODULE) \ @@ -1938,6 +1940,9 @@ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllq $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mpool.obj: ..\..\lib\cmn\Mpool.cpp $(CXX) /c /nologo /TP /Fo$@ $(DLLQSECMNXX_CXXFLAGS) ..\..\lib\cmn\Mpool.cpp +$(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_String.obj: ..\..\lib\cmn\String.cpp + $(CXX) /c /nologo /TP /Fo$@ $(DLLQSECMNXX_CXXFLAGS) ..\..\lib\cmn\String.cpp + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mmgr.obj: ..\..\lib\cmn\Mmgr.cpp $(CXX) /c /nologo /TP /Fo$@ $(LIBQSECMNXX_CXXFLAGS) ..\..\lib\cmn\Mmgr.cpp @@ -1953,6 +1958,9 @@ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libq $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj: ..\..\lib\cmn\Mpool.cpp $(CXX) /c /nologo /TP /Fo$@ $(LIBQSECMNXX_CXXFLAGS) ..\..\lib\cmn\Mpool.cpp +$(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_String.obj: ..\..\lib\cmn\String.cpp + $(CXX) /c /nologo /TP /Fo$@ $(LIBQSECMNXX_CXXFLAGS) ..\..\lib\cmn\String.cpp + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqseawkxx_Awk.obj: ..\..\lib\awk\Awk.cpp $(CXX) /c /nologo /TP /Fo$@ $(DLLQSEAWKXX_CXXFLAGS) ..\..\lib\awk\Awk.cpp diff --git a/qse/bld/win32-watcom/makefile b/qse/bld/win32-watcom/makefile index 60a4f15f..695a9f1e 100644 --- a/qse/bld/win32-watcom/makefile +++ b/qse/bld/win32-watcom/makefile @@ -661,7 +661,8 @@ DLLQSECMNXX_OBJECTS = & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_StdMmgr.obj & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_HeapMmgr.obj & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mmged.obj & - $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mpool.obj + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mpool.obj & + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_String.obj LIBQSECMNXX_CXXFLAGS = -i=..\..\include $(CPPFLAGS_BUILD) $(CPPFLAGS_CHAR) & $(CPPFLAGS_XCMGRS) $(CPPFLAGS_BUNDLED_UNICODE) $(CPPFLAGS_STATIC_MODULE) & $(CPPFLAGS_TCPV40HDRS) -wx $(__DEBUG_INFO) -bm -ot -ox -xs $(CPPFLAGS) & @@ -671,7 +672,8 @@ LIBQSECMNXX_OBJECTS = & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_StdMmgr.obj & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_HeapMmgr.obj & $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mmged.obj & - $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj & + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_String.obj DLLQSEAWKXX_CXXFLAGS = -bd -i=..\..\include $(CPPFLAGS_BUILD) $(CPPFLAGS_CHAR) & $(CPPFLAGS_XCMGRS) $(CPPFLAGS_BUNDLED_UNICODE) $(CPPFLAGS_STATIC_MODULE) & $(CPPFLAGS_TCPV40HDRS) -wx $(__DEBUG_INFO) -bm -ot -ox -xs $(CPPFLAGS) & @@ -1900,6 +1902,9 @@ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllq $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_Mpool.obj : .AUTODEPEND ..\..\lib\cmn\Mpool.cpp $(CXX) -bt=nt -zq -fo=$^@ $(DLLQSECMNXX_CXXFLAGS) $< +$(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqsecmnxx_String.obj : .AUTODEPEND ..\..\lib\cmn\String.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(DLLQSECMNXX_CXXFLAGS) $< + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mmgr.obj : .AUTODEPEND ..\..\lib\cmn\Mmgr.cpp $(CXX) -bt=nt -zq -fo=$^@ $(LIBQSECMNXX_CXXFLAGS) $< @@ -1915,6 +1920,9 @@ $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libq $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_Mpool.obj : .AUTODEPEND ..\..\lib\cmn\Mpool.cpp $(CXX) -bt=nt -zq -fo=$^@ $(LIBQSECMNXX_CXXFLAGS) $< +$(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\libqsecmnxx_String.obj : .AUTODEPEND ..\..\lib\cmn\String.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(LIBQSECMNXX_CXXFLAGS) $< + $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)\dllqseawkxx_Awk.obj : .AUTODEPEND ..\..\lib\awk\Awk.cpp $(CXX) -bt=nt -zq -fo=$^@ $(DLLQSEAWKXX_CXXFLAGS) $< diff --git a/qse/include/qse/Exception.hpp b/qse/include/qse/Exception.hpp index 3f0ce7c6..366e625e 100644 --- a/qse/include/qse/Exception.hpp +++ b/qse/include/qse/Exception.hpp @@ -31,8 +31,7 @@ /// \file /// Provides the Exception class. -#include -#include +#include ///////////////////////////////// QSE_BEGIN_NAMESPACE(QSE) diff --git a/qse/include/qse/Growable.hpp b/qse/include/qse/Growable.hpp index c9556393..f7ac0a1d 100644 --- a/qse/include/qse/Growable.hpp +++ b/qse/include/qse/Growable.hpp @@ -30,8 +30,7 @@ /// \file /// Provides classes for handling size growth including buffer growth. -#include -#include +#include ///////////////////////////////// QSE_BEGIN_NAMESPACE(QSE) diff --git a/qse/include/qse/Hashable.hpp b/qse/include/qse/Hashable.hpp index 2a1b37b8..8ab1da84 100644 --- a/qse/include/qse/Hashable.hpp +++ b/qse/include/qse/Hashable.hpp @@ -30,8 +30,7 @@ /// \file /// Privides the Hashable interface class. -#include -#include +#include ///////////////////////////////// QSE_BEGIN_NAMESPACE(QSE) diff --git a/qse/include/qse/Types.hpp b/qse/include/qse/Types.hpp index da9f98b5..4013295d 100644 --- a/qse/include/qse/Types.hpp +++ b/qse/include/qse/Types.hpp @@ -27,11 +27,43 @@ #ifndef _QSE_TYPES_HPP_ #define _QSE_TYPES_HPP_ +/// \file +/// Defines aliases to various QSE types in a class and holds various feature +/// configuration options. + #include #include -/// \file -/// Defines a class containg aliases to various QSE types. +/// The QSE_ENABLE_CPP11_MOVE macro enables C++11 move semantics +/// in various classes. +#if (__cplusplus >= 201103L) // C++11 +# define QSE_ENABLE_CPP11_MOVE 1 +#endif + + +#if defined(QSE_ENABLE_CPP11_MOVE) + + template struct QSE_CPP_RMREF { typedef T Type;} ; + template struct QSE_CPP_RMREF { typedef T Type; }; + template struct QSE_CPP_RMREF { typedef T Type; }; + + template inline + typename QSE_CPP_RMREF::Type&& QSE_CPP_RVREF(T&& v) + { + return (typename QSE_CPP_RMREF::Type&&)v; + } +#else + + /* + template inline + T& QSE_CPP_RVREF(T& v) { return (T&)v; } + + template inline + const T& QSE_CPP_RVREF(const T& v) { return (const T&)v; } + */ + #define QSE_CPP_RVREF(x) x +#endif + ///////////////////////////////// QSE_BEGIN_NAMESPACE(QSE) diff --git a/qse/include/qse/Uncopyable.hpp b/qse/include/qse/Uncopyable.hpp index a3f59644..e465778d 100644 --- a/qse/include/qse/Uncopyable.hpp +++ b/qse/include/qse/Uncopyable.hpp @@ -30,8 +30,7 @@ /// \file /// Provides the Uncopyable class. -#include -#include +#include ///////////////////////////////// QSE_BEGIN_NAMESPACE(QSE) diff --git a/qse/include/qse/cmn/Array.hpp b/qse/include/qse/cmn/Array.hpp index f343d421..f81ebe6b 100644 --- a/qse/include/qse/cmn/Array.hpp +++ b/qse/include/qse/cmn/Array.hpp @@ -122,7 +122,7 @@ public: } } -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) Array (SelfType&& array): Mmged(array.getMmgr()), @@ -162,7 +162,7 @@ public: return *this; } -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) SelfType& operator= (SelfType&& array) { if (this != &array) @@ -227,7 +227,7 @@ protected: return tmp; } -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) T* clone_buffer_by_moving (T* srcbuf, qse_size_t capa, qse_size_t cnt) { QSE_ASSERT (capa > 0); @@ -292,7 +292,7 @@ protected: } } -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) void put_item_by_moving (qse_size_t index, T&& value) { if (index >= this->count) @@ -418,6 +418,13 @@ public: this->update (index, value); } +#if defined(QSE_ENABLE_CPP11_MOVE) + void setValueAt (qse_size_t index, T&& value) + { + this->update (index, (T&&)value); + } +#endif + protected: void secure_slot (qse_size_t index) { @@ -445,7 +452,7 @@ protected: // shift the existing elements to the back by one slot. for (qse_size_t i = this->count; i > index; i--) { - #if (__cplusplus >= 201103L) // C++11 + #if defined(QSE_ENABLE_CPP11_MOVE) this->put_item_by_moving (i, (T&&)this->buffer[i - 1]); #else this->put_item (i, this->buffer[i - 1]); @@ -482,7 +489,7 @@ public: return index; } -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) qse_size_t insert (qse_size_t index, T&& value) { // Unlike insert() in RedBlackTree and HashList, @@ -509,7 +516,7 @@ public: return index; } -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) qse_size_t update (qse_size_t index, T&& value) { QSE_ASSERT (index < this->count); @@ -527,7 +534,7 @@ public: return this->insert (index, value); } -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) qse_size_t upsert (qse_size_t index, T&& value) { if (index < this->count) @@ -545,7 +552,7 @@ public: return this->insert (index, value); } -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) qse_size_t ensert (qse_size_t index, T&& value) { if (index < this->count) @@ -584,7 +591,7 @@ public: //this->_positioner (this->buffer[j], j); // 2. operator assignment - #if (__cplusplus >= 201103L) // C++11 + #if defined(QSE_ENABLE_CPP11_MOVE) this->buffer[j] = (T&&)this->buffer[i]; #else this->buffer[j] = this->buffer[i]; @@ -684,7 +691,7 @@ public: qse_size_t cnt = this->count; if (cnt > capa) cnt = capa; - #if (__cplusplus >= 201103L) // C++11 + #if defined(QSE_ENABLE_CPP11_MOVE) T* tmp = this->clone_buffer_by_moving (this->buffer, capa, cnt); #else T* tmp = this->clone_buffer (this->buffer, capa, cnt); @@ -748,39 +755,61 @@ public: } #endif - void rotate (int dir, qse_size_t n) + enum RotateDirection + { + ROTATE_LEFT, + ROTATE_RIGHT + }; + + void rotate (RotateDirection dir, qse_size_t n) { qse_size_t first, last, cnt, index, nk; T c; - if (dir == 0) return; if ((n %= this->count) == 0) return; - if (dir > 0) n = this->count - n; + if (dir == ROTATE_RIGHT) n = this->count - n; first = 0; nk = this->count - n; cnt = 0; while (cnt < n) { last = first + nk; index = first; - c = this->buffer[first]; + #if defined(QSE_ENABLE_CPP11_MOVE) + c = (T&&)this->buffer[index]; + #else + c = this->buffer[index]; + #endif while (1) { cnt++; while (index < nk) { + #if defined(QSE_ENABLE_CPP11_MOVE) + this->buffer[index] = (T&&)this->buffer[index + n]; + #else this->buffer[index] = this->buffer[index + n]; + #endif this->_positioner (this->buffer[index], index); index += n; } if (index == last) break; + #if defined(QSE_ENABLE_CPP11_MOVE) + this->buffer[index] = (T&&)this->buffer[index - nk]; + #else this->buffer[index] = this->buffer[index - nk]; + #endif this->_positioner (this->buffer[index], index); index -= nk; } + + #if defined(QSE_ENABLE_CPP11_MOVE) + this->buffer[last] = (T&&)c; + #else this->buffer[last] = c; + #endif this->_positioner (this->buffer[last], last); first++; } diff --git a/qse/include/qse/cmn/Association.hpp b/qse/include/qse/cmn/Association.hpp index 094f6852..d1e8de28 100644 --- a/qse/include/qse/cmn/Association.hpp +++ b/qse/include/qse/cmn/Association.hpp @@ -27,8 +27,7 @@ #ifndef _QSE_CMN_ASSOCIATION_HPP_ #define _QSE_CMN_ASSOCIATION_HPP_ -#include -#include +#include ///////////////////////////////// QSE_BEGIN_NAMESPACE(QSE) diff --git a/qse/include/qse/cmn/BinaryHeap.hpp b/qse/include/qse/cmn/BinaryHeap.hpp index 3bbb0233..8001859a 100644 --- a/qse/include/qse/cmn/BinaryHeap.hpp +++ b/qse/include/qse/cmn/BinaryHeap.hpp @@ -135,7 +135,7 @@ public: { } -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) BinaryHeap (SelfType& heap): ParentType (heap) { } @@ -154,7 +154,7 @@ public: return *this; } -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) SelfType& operator= (SelfType&& heap) { if (this != &heap) @@ -212,13 +212,13 @@ public: return this->sift_up(index); } -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) qse_size_t insert (T&& value) { qse_size_t index = this->count; // add the item at the back of the array - ParentType::insert (index, (T&&)value); + ParentType::insert (index, QSE_CPP_RVREF(value)); // move the item up to the top if it's greater than the up item return this->sift_up(index); @@ -230,19 +230,15 @@ public: qse_size_t update (qse_size_t index, const T& value) { T old = this->buffer[index]; - ParentType::update (index, value); - return (this->greater_than(value, old))? this->sift_up(index): this->sift_down(index); } -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) qse_size_t update (qse_size_t index, T&& value) { - T old = this->buffer[index]; - - ParentType::update (index, (T&&)value); - + T old = QSE_CPP_RVREF(this->buffer[index]); + ParentType::update (index, QSE_CPP_RVREF(value)); return (this->greater_than(value, old))? this->sift_up(index): this->sift_down(index); } #endif @@ -252,19 +248,25 @@ public: { QSE_ASSERT (index < this->count); -// TODO: move semantics herr -//BEGIN - // copy the last item to the position to remove - T old = this->buffer[index]; + if (this->count == 1) + { + QSE_ASSERT (index == 0); + ParentType::remove (this->count - 1); + } + else if (this->count > 1) + { + // store the item to remove temporarily + T old = QSE_CPP_RVREF(this->buffer[index]); - ParentType::update (index, this->buffer[this->count - 1]); -// END.. + // copy the last item to the position to remove + ParentType::update (index, QSE_CPP_RVREF(this->buffer[this->count - 1])); - // delete the last item - ParentType::remove (this->count - 1); - - // relocate the item - (this->greater_than (this->buffer[index], old))? this->sift_up(index): this->sift_down(index); + // delete the last item + ParentType::remove (this->count - 1); + + // relocate the item + (this->greater_than (this->buffer[index], old))? this->sift_up(index): this->sift_down(index); + } } protected: @@ -275,18 +277,18 @@ protected: up = QSE_BINARY_HEAP_UP(index); if (index > 0 && this->greater_than(this->buffer[index], this->buffer[up])) { - T item = this->buffer[index]; + T item = QSE_CPP_RVREF(this->buffer[index]); do { - ParentType::setValueAt (index, this->buffer[up]); + ParentType::setValueAt (index, QSE_CPP_RVREF(this->buffer[up])); index = up; up = QSE_BINARY_HEAP_UP(up); } while (index > 0 && this->greater_than(item, this->buffer[up])); - ParentType::setValueAt (index, item); + ParentType::setValueAt (index, QSE_CPP_RVREF(item)); } return index; @@ -301,15 +303,15 @@ protected: // if at least 1 child is under the 'index' position // perform sifting - T item = this->buffer[index]; + T item = QSE_CPP_RVREF(this->buffer[index]); do { qse_size_t left, right, greater; - + left = QSE_BINARY_HEAP_LEFT(index); right = QSE_BINARY_HEAP_RIGHT(index); - + // choose the larger one between 2 BinaryHeap if (right < this->count && this->greater_than(this->buffer[right], this->buffer[left])) @@ -325,12 +327,12 @@ protected: if (this->greater_than(item, this->buffer[greater])) break; - ParentType::setValueAt (index, this->buffer[greater]); + ParentType::setValueAt (index, QSE_CPP_RVREF(this->buffer[greater])); index = greater; } while (index < half_data_count); - ParentType::setValueAt (index, item); + ParentType::setValueAt (index, QSE_CPP_RVREF(item)); } return index; diff --git a/qse/include/qse/cmn/HashList.hpp b/qse/include/qse/cmn/HashList.hpp index e21def12..a49521b0 100644 --- a/qse/include/qse/cmn/HashList.hpp +++ b/qse/include/qse/cmn/HashList.hpp @@ -764,8 +764,14 @@ private: { // destruction in response to 'placement new' - // call the destructor - this->datum_list->~DatumList(); + #if defined(__BORLANDC__) + // BCC55 doesn't support the explicit destructor call. + // instead, call shatter() which is actually called by ~DatumList(). + this->datum_list->shatter (); + #else + // call the destructor for completeness + this->datum_list->~DatumList (); + #endif // free the memory ::operator delete (this->datum_list, this->getMmgr()); } diff --git a/qse/include/qse/cmn/LinkedList.hpp b/qse/include/qse/cmn/LinkedList.hpp index a9499290..822545ca 100644 --- a/qse/include/qse/cmn/LinkedList.hpp +++ b/qse/include/qse/cmn/LinkedList.hpp @@ -207,6 +207,11 @@ public: }; ~LinkedList () + { + this->shatter (); + } + + void shatter () { this->clear (true); } diff --git a/qse/include/qse/cmn/Mmgr.hpp b/qse/include/qse/cmn/Mmgr.hpp index dab33d23..01426b92 100644 --- a/qse/include/qse/cmn/Mmgr.hpp +++ b/qse/include/qse/cmn/Mmgr.hpp @@ -27,8 +27,6 @@ #ifndef _QSE_CMN_MMGR_HPP_ #define _QSE_CMN_MMGR_HPP_ -#include -#include #include ///////////////////////////////// diff --git a/qse/include/qse/cmn/StrBase.hpp b/qse/include/qse/cmn/StrBase.hpp index 33887921..79366dd3 100644 --- a/qse/include/qse/cmn/StrBase.hpp +++ b/qse/include/qse/cmn/StrBase.hpp @@ -77,7 +77,7 @@ protected: while (size > 0) this->buffer[--size] = c; } - void dispose (Mmgr* mmgr) + void shatter (Mmgr* mmgr) { QSE_ASSERT (this->buffer != QSE_NULL); ::operator delete (this->buffer, mmgr); @@ -283,8 +283,21 @@ protected: { if (sd->deref () <= 0) { - sd->dispose (this->getMmgr()); + // i can't pass an argument to the destructor. + // destroy the actual contents via the shatter() funtion + // call the destructor for completeness only + sd->shatter (this->getMmgr()); + #if defined(__BORLANDC__) + // BCC55 doesn't support calling the destructor explicitly. + // anyway, it's safe not to call it for the way i destroy + // the object using the shatter() call above + // + // DO NOTHING + // + #else + // call the destructor sd->~StringItem (); + #endif ::operator delete (sd, this->getMmgr()); } } diff --git a/qse/lib/awk/mod-math.c b/qse/lib/awk/mod-math.c index a602bd27..7aed1d25 100644 --- a/qse/lib/awk/mod-math.c +++ b/qse/lib/awk/mod-math.c @@ -42,7 +42,7 @@ # if defined(_WIN32) || defined(__OS2__) || defined(__DOS__) # define HAVE_CEIL # define HAVE_FLOOR -# if !defined(__WATCOMC__) +# if !defined(__WATCOMC__) && !defined(__BORLANDC__) # define HAVE_ROUND # endif # define HAVE_SINH diff --git a/qse/samples/cmn/Makefile.am b/qse/samples/cmn/Makefile.am index 47cb30c0..e72969d2 100644 --- a/qse/samples/cmn/Makefile.am +++ b/qse/samples/cmn/Makefile.am @@ -98,7 +98,7 @@ if ENABLE_CXX #rex02_CXXFLAGS = -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread #rex02_LDFLAGS = -pthread -Wl,-Bsymbolic-functions -lwx_gtk2ud_richtext-2.8 -lwx_gtk2ud_aui-2.8 -lwx_gtk2ud_xrc-2.8 -lwx_gtk2ud_qa-2.8 -lwx_gtk2ud_html-2.8 -lwx_gtk2ud_adv-2.8 -lwx_gtk2ud_core-2.8 -lwx_baseud_xml-2.8 -lwx_baseud_net-2.8 -lwx_baseud-2.8 -bin_PROGRAMS += arr01 arr02 bh01 hl01 htb02 rbt02 rbt03 sp01 sp02 str02 +bin_PROGRAMS += arr01 arr02 bh01 bh02 hl01 htb02 rbt02 rbt03 sp01 sp02 str02 arr01_SOURCES = arr01.cpp arr01_LDADD = $(LDADD) -lqsecmnxx @@ -109,6 +109,9 @@ arr02_LDADD = $(LDADD) -lqsecmnxx bh01_SOURCES = bh01.cpp bh01_LDADD = $(LDADD) -lqsecmnxx +bh02_SOURCES = bh02.cpp +bh02_LDADD = $(LDADD) -lqsecmnxx + hl01_SOURCES = hl01.cpp hl01_LDADD = $(LDADD) -lqsecmnxx diff --git a/qse/samples/cmn/Makefile.in b/qse/samples/cmn/Makefile.in index 099573a6..cfdc9e0e 100644 --- a/qse/samples/cmn/Makefile.in +++ b/qse/samples/cmn/Makefile.in @@ -68,7 +68,7 @@ bin_PROGRAMS = chr01$(EXEEXT) dir01$(EXEEXT) dll$(EXEEXT) \ #rex02_SOURCES = rex02.cpp #rex02_CXXFLAGS = -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread #rex02_LDFLAGS = -pthread -Wl,-Bsymbolic-functions -lwx_gtk2ud_richtext-2.8 -lwx_gtk2ud_aui-2.8 -lwx_gtk2ud_xrc-2.8 -lwx_gtk2ud_qa-2.8 -lwx_gtk2ud_html-2.8 -lwx_gtk2ud_adv-2.8 -lwx_gtk2ud_core-2.8 -lwx_baseud_xml-2.8 -lwx_baseud_net-2.8 -lwx_baseud-2.8 -@ENABLE_CXX_TRUE@am__append_2 = arr01 arr02 bh01 hl01 htb02 rbt02 rbt03 sp01 sp02 str02 +@ENABLE_CXX_TRUE@am__append_2 = arr01 arr02 bh01 bh02 hl01 htb02 rbt02 rbt03 sp01 sp02 str02 subdir = samples/cmn DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -87,9 +87,9 @@ CONFIG_HEADER = $(top_builddir)/include/qse/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @ENABLE_CXX_TRUE@am__EXEEXT_1 = arr01$(EXEEXT) arr02$(EXEEXT) \ -@ENABLE_CXX_TRUE@ bh01$(EXEEXT) hl01$(EXEEXT) htb02$(EXEEXT) \ -@ENABLE_CXX_TRUE@ rbt02$(EXEEXT) rbt03$(EXEEXT) sp01$(EXEEXT) \ -@ENABLE_CXX_TRUE@ sp02$(EXEEXT) str02$(EXEEXT) +@ENABLE_CXX_TRUE@ bh01$(EXEEXT) bh02$(EXEEXT) hl01$(EXEEXT) \ +@ENABLE_CXX_TRUE@ htb02$(EXEEXT) rbt02$(EXEEXT) rbt03$(EXEEXT) \ +@ENABLE_CXX_TRUE@ sp01$(EXEEXT) sp02$(EXEEXT) str02$(EXEEXT) am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am__arr01_SOURCES_DIST = arr01.cpp @@ -110,6 +110,10 @@ am__bh01_SOURCES_DIST = bh01.cpp @ENABLE_CXX_TRUE@am_bh01_OBJECTS = bh01.$(OBJEXT) bh01_OBJECTS = $(am_bh01_OBJECTS) @ENABLE_CXX_TRUE@bh01_DEPENDENCIES = $(am__DEPENDENCIES_3) +am__bh02_SOURCES_DIST = bh02.cpp +@ENABLE_CXX_TRUE@am_bh02_OBJECTS = bh02.$(OBJEXT) +bh02_OBJECTS = $(am_bh02_OBJECTS) +@ENABLE_CXX_TRUE@bh02_DEPENDENCIES = $(am__DEPENDENCIES_3) am_chr01_OBJECTS = chr01.$(OBJEXT) chr01_OBJECTS = $(am_chr01_OBJECTS) chr01_LDADD = $(LDADD) @@ -341,14 +345,15 @@ AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(arr01_SOURCES) $(arr02_SOURCES) $(bh01_SOURCES) \ - $(chr01_SOURCES) dir01.c $(dll_SOURCES) $(env01_SOURCES) \ - $(fio01_SOURCES) $(fio02_SOURCES) $(fma_SOURCES) \ - $(fmt01_SOURCES) $(fmt02_SOURCES) $(fs01_SOURCES) fs02.c \ - fs03.c $(glob01_SOURCES) $(hl01_SOURCES) $(htb01_SOURCES) \ - $(htb02_SOURCES) $(ipad01_SOURCES) $(lda_SOURCES) \ - $(main01_SOURCES) $(main02_SOURCES) $(mbwc01_SOURCES) \ - $(mbwc02_SOURCES) $(nwad01_SOURCES) nwif01.c nwif02.c \ - $(oht_SOURCES) $(path01_SOURCES) $(pio_SOURCES) $(pma_SOURCES) \ + $(bh02_SOURCES) $(chr01_SOURCES) dir01.c $(dll_SOURCES) \ + $(env01_SOURCES) $(fio01_SOURCES) $(fio02_SOURCES) \ + $(fma_SOURCES) $(fmt01_SOURCES) $(fmt02_SOURCES) \ + $(fs01_SOURCES) fs02.c fs03.c $(glob01_SOURCES) \ + $(hl01_SOURCES) $(htb01_SOURCES) $(htb02_SOURCES) \ + $(ipad01_SOURCES) $(lda_SOURCES) $(main01_SOURCES) \ + $(main02_SOURCES) $(mbwc01_SOURCES) $(mbwc02_SOURCES) \ + $(nwad01_SOURCES) nwif01.c nwif02.c $(oht_SOURCES) \ + $(path01_SOURCES) $(pio_SOURCES) $(pma_SOURCES) \ $(rbt01_SOURCES) $(rbt02_SOURCES) $(rbt03_SOURCES) \ $(rex01_SOURCES) $(sio01_SOURCES) $(sio02_SOURCES) \ $(sio03_SOURCES) $(sll_SOURCES) $(slmb01_SOURCES) \ @@ -356,16 +361,16 @@ SOURCES = $(arr01_SOURCES) $(arr02_SOURCES) $(bh01_SOURCES) \ $(str02_SOURCES) task01.c $(time_SOURCES) $(tre01_SOURCES) \ uri01.c $(xma_SOURCES) DIST_SOURCES = $(am__arr01_SOURCES_DIST) $(am__arr02_SOURCES_DIST) \ - $(am__bh01_SOURCES_DIST) $(chr01_SOURCES) dir01.c \ - $(dll_SOURCES) $(env01_SOURCES) $(fio01_SOURCES) \ - $(fio02_SOURCES) $(fma_SOURCES) $(fmt01_SOURCES) \ - $(fmt02_SOURCES) $(fs01_SOURCES) fs02.c fs03.c \ - $(glob01_SOURCES) $(am__hl01_SOURCES_DIST) $(htb01_SOURCES) \ - $(am__htb02_SOURCES_DIST) $(ipad01_SOURCES) $(lda_SOURCES) \ - $(main01_SOURCES) $(main02_SOURCES) $(mbwc01_SOURCES) \ - $(mbwc02_SOURCES) $(nwad01_SOURCES) nwif01.c nwif02.c \ - $(oht_SOURCES) $(path01_SOURCES) $(pio_SOURCES) $(pma_SOURCES) \ - $(rbt01_SOURCES) $(am__rbt02_SOURCES_DIST) \ + $(am__bh01_SOURCES_DIST) $(am__bh02_SOURCES_DIST) \ + $(chr01_SOURCES) dir01.c $(dll_SOURCES) $(env01_SOURCES) \ + $(fio01_SOURCES) $(fio02_SOURCES) $(fma_SOURCES) \ + $(fmt01_SOURCES) $(fmt02_SOURCES) $(fs01_SOURCES) fs02.c \ + fs03.c $(glob01_SOURCES) $(am__hl01_SOURCES_DIST) \ + $(htb01_SOURCES) $(am__htb02_SOURCES_DIST) $(ipad01_SOURCES) \ + $(lda_SOURCES) $(main01_SOURCES) $(main02_SOURCES) \ + $(mbwc01_SOURCES) $(mbwc02_SOURCES) $(nwad01_SOURCES) nwif01.c \ + nwif02.c $(oht_SOURCES) $(path01_SOURCES) $(pio_SOURCES) \ + $(pma_SOURCES) $(rbt01_SOURCES) $(am__rbt02_SOURCES_DIST) \ $(am__rbt03_SOURCES_DIST) $(rex01_SOURCES) $(sio01_SOURCES) \ $(sio02_SOURCES) $(sio03_SOURCES) $(sll_SOURCES) \ $(slmb01_SOURCES) $(am__sp01_SOURCES_DIST) \ @@ -601,6 +606,8 @@ xma_SOURCES = xma.c @ENABLE_CXX_TRUE@arr02_LDADD = $(LDADD) -lqsecmnxx @ENABLE_CXX_TRUE@bh01_SOURCES = bh01.cpp @ENABLE_CXX_TRUE@bh01_LDADD = $(LDADD) -lqsecmnxx +@ENABLE_CXX_TRUE@bh02_SOURCES = bh02.cpp +@ENABLE_CXX_TRUE@bh02_LDADD = $(LDADD) -lqsecmnxx @ENABLE_CXX_TRUE@hl01_SOURCES = hl01.cpp @ENABLE_CXX_TRUE@hl01_LDADD = $(LDADD) -lqsecmnxx @ENABLE_CXX_TRUE@htb02_SOURCES = htb02.cpp @@ -704,6 +711,9 @@ arr02$(EXEEXT): $(arr02_OBJECTS) $(arr02_DEPENDENCIES) $(EXTRA_arr02_DEPENDENCIE bh01$(EXEEXT): $(bh01_OBJECTS) $(bh01_DEPENDENCIES) $(EXTRA_bh01_DEPENDENCIES) @rm -f bh01$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(bh01_OBJECTS) $(bh01_LDADD) $(LIBS) +bh02$(EXEEXT): $(bh02_OBJECTS) $(bh02_DEPENDENCIES) $(EXTRA_bh02_DEPENDENCIES) + @rm -f bh02$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(bh02_OBJECTS) $(bh02_LDADD) $(LIBS) chr01$(EXEEXT): $(chr01_OBJECTS) $(chr01_DEPENDENCIES) $(EXTRA_chr01_DEPENDENCIES) @rm -f chr01$(EXEEXT) $(AM_V_CCLD)$(LINK) $(chr01_OBJECTS) $(chr01_LDADD) $(LIBS) @@ -855,6 +865,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arr01.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arr02.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bh01.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bh02.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chr01.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dir01.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dll.Po@am__quote@ diff --git a/qse/samples/cmn/arr01.cpp b/qse/samples/cmn/arr01.cpp index 8c47dbaf..e9fe031d 100644 --- a/qse/samples/cmn/arr01.cpp +++ b/qse/samples/cmn/arr01.cpp @@ -124,7 +124,7 @@ int main () printf ("--------------------\n"); h3.setCapacity (6); h3.insert (6, "good?"); - h3.rotate (1, h3.getSize() / 2); + h3.rotate (StrArray::ROTATE_RIGHT, h3.getSize() / 2); printf ("[%s] [%s]\n", h3.getValueAt(5).getBuffer(), h3.getValueAt(6).getBuffer()); printf ("%d\n", (int)h3.getSize()); diff --git a/qse/samples/cmn/arr02.cpp b/qse/samples/cmn/arr02.cpp index ae9c7a5c..a5433591 100644 --- a/qse/samples/cmn/arr02.cpp +++ b/qse/samples/cmn/arr02.cpp @@ -19,7 +19,7 @@ printf ("constructor %d\n", q); printf ("copy constructor %d\n", *q.x); } -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) Julia (Julia&& q) { printf ("move constructor %d\n", *q.x); @@ -50,7 +50,7 @@ printf ("operator= %d\n", *q.x); return *this; } -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) Julia& operator= (Julia&& q) { if (this != &q) @@ -83,11 +83,23 @@ int main () a0.remove (2, 5); a0.update (5, Julia(9999)); -#if (__cplusplus >= 201103L) // C++11 +#if defined(QSE_ENABLE_CPP11_MOVE) QSE::Array a1 ((QSE::Array&&)a0); #else QSE::Array a1 (a0); #endif printf ("OK: %d %d\n", (int)a0.getSize(), (int)a1.getSize()); + + + for (qse_size_t i = 0; i < a1.getSize(); i++) + { + printf ("ITEM: %d => %d\n", (int)i, *a1[i].x); + } + printf ("----------------\n"); + a1.rotate (QSE::Array::ROTATE_LEFT, 2); + for (qse_size_t i = 0; i < a1.getSize(); i++) + { + printf ("ITEM: %d => %d\n", (int)i, *a1[i].x); + } return 0; } diff --git a/qse/samples/cmn/bh02.cpp b/qse/samples/cmn/bh02.cpp new file mode 100644 index 00000000..a035683c --- /dev/null +++ b/qse/samples/cmn/bh02.cpp @@ -0,0 +1,90 @@ +#include + +#include +#include +#include +#include +#include + +class Julia +{ +public: + Julia (int q = 0): x(QSE_NULL) + { + this->x = new int (q); + } + + Julia (const Julia& q): x(QSE_NULL) + { + this->x = new int (*q.x); + } + +#if defined(QSE_ENABLE_CPP11_MOVE) + Julia (Julia&& q) + { + this->x = q.x; + q.x = QSE_NULL; + } +#endif + + ~Julia() + { + if (this->x) + { + delete this->x; + } + } + + Julia& operator= (const Julia& q) + { + if (this != &q) + { + if (this->x) { delete this->x; this->x = QSE_NULL; } + this->x = new int (*q.x); + } + + return *this; + } + +#if defined(QSE_ENABLE_CPP11_MOVE) + Julia& operator= (Julia&& q) + { + if (this != &q) + { + if (this->x) { delete this->x; this->x = QSE_NULL; } + this->x = q.x; + q.x = QSE_NULL; + } + + return *this; + } +#endif + + bool operator> (const Julia& q) const { return *this->x > *q.x; } + int* x; +}; + +typedef QSE::BinaryHeap JuliaHeap; + +int main () +{ + JuliaHeap jh; + qse_uint32_t x; + qse_ntime_t nt; + + qse_gettime (&nt); + + x = nt.sec + nt.nsec; + + for (int i = 0; i < 100; i++) + { + x = qse_rand31(x); + jh.insert (Julia((int)x % 100)); + } + + while (!jh.isEmpty()) + { + printf ("%d\n", *jh.getValueAt(0).x); + jh.remove (0); + } +}