added quite a few sample programs
This commit is contained in:
parent
3793785e7c
commit
cb62c4ecd1
@ -75,7 +75,6 @@ public:
|
||||
INVALID_INDEX = ~(qse_size_t)0
|
||||
};
|
||||
|
||||
private:
|
||||
void init_array (int capacity)
|
||||
{
|
||||
if (capacity <= 0)
|
||||
@ -94,19 +93,19 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
Array (qse_size_t capacity = DEFAULT_CAPACITY): Mmged (QSE_NULL)
|
||||
Array (qse_size_t capacity = DEFAULT_CAPACITY): Mmged(QSE_NULL)
|
||||
{
|
||||
this->init_array (capacity);
|
||||
}
|
||||
|
||||
Array (Mmgr* mmgr, qse_size_t capacity = DEFAULT_CAPACITY): Mmged (mmgr)
|
||||
Array (Mmgr* mmgr, qse_size_t capacity = DEFAULT_CAPACITY): Mmged(mmgr)
|
||||
{
|
||||
this->init_array (capacity);
|
||||
}
|
||||
|
||||
Array (const SelfType& array):
|
||||
Mmged (array.getMmgr()),
|
||||
count (0), capacity (0), buffer (QSE_NULL)
|
||||
Mmged(array.getMmgr()),
|
||||
count(0), capacity(0), buffer(QSE_NULL)
|
||||
{
|
||||
if (array.buffer)
|
||||
{
|
||||
|
@ -320,7 +320,7 @@ public:
|
||||
typedef RedBlackTreeComparator<T> DefaultComparator;
|
||||
|
||||
private:
|
||||
void init_tree (qse_size_t mpb_size)
|
||||
void init_tree ()
|
||||
{
|
||||
#if defined(QSE_REDBLACKTREE_ALLOCATE_NIL)
|
||||
// create a nil object. note it doesn't go into the memory pool.
|
||||
@ -340,19 +340,19 @@ public:
|
||||
RedBlackTree (qse_size_t mpb_size = 0):
|
||||
Mmged(QSE_NULL), mp(QSE_NULL, QSE_SIZEOF(Node), mpb_size), node_count(0)
|
||||
{
|
||||
this->init_tree (mpb_size);
|
||||
this->init_tree ();
|
||||
}
|
||||
|
||||
RedBlackTree (Mmgr* mmgr, qse_size_t mpb_size = 0):
|
||||
Mmged (mmgr), mp (mmgr, QSE_SIZEOF(Node), mpb_size), node_count (0)
|
||||
Mmged(mmgr), mp(mmgr, QSE_SIZEOF(Node), mpb_size), node_count(0)
|
||||
{
|
||||
this->init_tree (mpb_size);
|
||||
this->init_tree ();
|
||||
}
|
||||
|
||||
RedBlackTree (const SelfType& rbt):
|
||||
Mmged (rbt.getMmgr()),
|
||||
mp (rbt.getMmgr(), rbt.mp.getDatumSize(), rbt.mp.getBlockSize()),
|
||||
node_count (0)
|
||||
Mmged(rbt.getMmgr()),
|
||||
mp(rbt.getMmgr(), rbt.mp.getDatumSize(), rbt.mp.getBlockSize()),
|
||||
node_count(0)
|
||||
{
|
||||
#if defined(QSE_REDBLACKTREE_ALLOCATE_NIL)
|
||||
// create a nil object. note it doesn't go into the memory pool.
|
||||
|
@ -135,9 +135,10 @@ void* qse_fma_alloc (qse_fma_t* fma, qse_size_t size)
|
||||
|
||||
if ((blk = fma->freeblk) == QSE_NULL)
|
||||
{
|
||||
if (add_chunk (fma) == QSE_NULL) return QSE_NULL;
|
||||
if (add_chunk(fma) == QSE_NULL) return QSE_NULL;
|
||||
blk = fma->freeblk;
|
||||
}
|
||||
|
||||
fma->freeblk = fma->freeblk->next;
|
||||
return blk;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ bin_PROGRAMS = \
|
||||
fs01 \
|
||||
fs02 \
|
||||
fs03 \
|
||||
htb \
|
||||
htb01 \
|
||||
glob01 \
|
||||
ipad01 \
|
||||
lda \
|
||||
@ -35,7 +35,7 @@ bin_PROGRAMS = \
|
||||
pio \
|
||||
pma \
|
||||
rex01 \
|
||||
rbt \
|
||||
rbt01 \
|
||||
sio01 \
|
||||
sio02 \
|
||||
sio03 \
|
||||
@ -67,7 +67,7 @@ fmt01_SOURCES = fmt01.c
|
||||
fmt02_SOURCES = fmt02.c
|
||||
fs01_SOURCES = fs01.c
|
||||
glob01_SOURCES = glob01.c
|
||||
htb_SOURCES = htb.c
|
||||
htb01_SOURCES = htb01.c
|
||||
ipad01_SOURCES = ipad01.c
|
||||
lda_SOURCES = lda.c
|
||||
main01_SOURCES = main01.c
|
||||
@ -80,7 +80,7 @@ path01_SOURCES = path01.c
|
||||
pio_SOURCES = pio.c
|
||||
pma_SOURCES = pma.c
|
||||
rex01_SOURCES = rex01.c
|
||||
rbt_SOURCES = rbt.c
|
||||
rbt01_SOURCES = rbt01.c
|
||||
sio01_SOURCES = sio01.c
|
||||
sio02_SOURCES = sio02.c
|
||||
sio03_SOURCES = sio03.c
|
||||
@ -98,4 +98,30 @@ 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 bh01 hl01 htb02 rbt02 rbt03 sp01 sp02
|
||||
|
||||
arr01_SOURCES = arr01.cpp
|
||||
arr01_LDADD = $(LDADD) -lqsecmnxx
|
||||
|
||||
bh01_SOURCES = bh01.cpp
|
||||
bh01_LDADD = $(LDADD) -lqsecmnxx
|
||||
|
||||
hl01_SOURCES = hl01.cpp
|
||||
hl01_LDADD = $(LDADD) -lqsecmnxx
|
||||
|
||||
htb02_SOURCES = htb02.cpp
|
||||
htb02_LDADD = $(LDADD) -lqsecmnxx
|
||||
|
||||
rbt02_SOURCES = rbt02.cpp #RedBlackTree
|
||||
rbt02_LDADD = $(LDADD) -lqsecmnxx
|
||||
|
||||
rbt03_SOURCES = rbt03.cpp #RedBlackTable
|
||||
rbt03_LDADD = $(LDADD) -lqsecmnxx
|
||||
|
||||
sp01_SOURCES = sp01.cpp # ScopedPtr
|
||||
sp01_LDADD = $(LDADD) -lqsecmnxx
|
||||
|
||||
sp02_SOURCES = sp02.cpp # SharedPtr
|
||||
sp02_LDADD = $(LDADD) -lqsecmnxx
|
||||
|
||||
endif
|
||||
|
@ -54,15 +54,21 @@ host_triplet = @host@
|
||||
bin_PROGRAMS = chr01$(EXEEXT) dir01$(EXEEXT) dll$(EXEEXT) \
|
||||
env01$(EXEEXT) fio01$(EXEEXT) fio02$(EXEEXT) fma$(EXEEXT) \
|
||||
fmt01$(EXEEXT) fmt02$(EXEEXT) fs01$(EXEEXT) fs02$(EXEEXT) \
|
||||
fs03$(EXEEXT) htb$(EXEEXT) glob01$(EXEEXT) ipad01$(EXEEXT) \
|
||||
fs03$(EXEEXT) htb01$(EXEEXT) glob01$(EXEEXT) ipad01$(EXEEXT) \
|
||||
lda$(EXEEXT) main01$(EXEEXT) main02$(EXEEXT) mbwc01$(EXEEXT) \
|
||||
mbwc02$(EXEEXT) nwad01$(EXEEXT) nwif01$(EXEEXT) \
|
||||
nwif02$(EXEEXT) oht$(EXEEXT) path01$(EXEEXT) pio$(EXEEXT) \
|
||||
pma$(EXEEXT) rex01$(EXEEXT) rbt$(EXEEXT) sio01$(EXEEXT) \
|
||||
pma$(EXEEXT) rex01$(EXEEXT) rbt01$(EXEEXT) sio01$(EXEEXT) \
|
||||
sio02$(EXEEXT) sio03$(EXEEXT) sll$(EXEEXT) slmb01$(EXEEXT) \
|
||||
str01$(EXEEXT) task01$(EXEEXT) time$(EXEEXT) tre01$(EXEEXT) \
|
||||
uri01$(EXEEXT) xma$(EXEEXT)
|
||||
uri01$(EXEEXT) xma$(EXEEXT) $(am__EXEEXT_1)
|
||||
@WCHAR_TRUE@@WIN32_TRUE@am__append_1 = $(UNICOWS_LIBS)
|
||||
|
||||
#bin_PROGRAMS += rex02
|
||||
#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 bh01 hl01 htb02 rbt02 rbt03 sp01 sp02
|
||||
subdir = samples/cmn
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
@ -80,17 +86,29 @@ mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
@ENABLE_CXX_TRUE@am__EXEEXT_1 = arr01$(EXEEXT) bh01$(EXEEXT) \
|
||||
@ENABLE_CXX_TRUE@ hl01$(EXEEXT) htb02$(EXEEXT) rbt02$(EXEEXT) \
|
||||
@ENABLE_CXX_TRUE@ rbt03$(EXEEXT) sp01$(EXEEXT) sp02$(EXEEXT)
|
||||
am__installdirs = "$(DESTDIR)$(bindir)"
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am_chr01_OBJECTS = chr01.$(OBJEXT)
|
||||
chr01_OBJECTS = $(am_chr01_OBJECTS)
|
||||
chr01_LDADD = $(LDADD)
|
||||
am__arr01_SOURCES_DIST = arr01.cpp
|
||||
@ENABLE_CXX_TRUE@am_arr01_OBJECTS = arr01.$(OBJEXT)
|
||||
arr01_OBJECTS = $(am_arr01_OBJECTS)
|
||||
am__DEPENDENCIES_1 =
|
||||
@WCHAR_TRUE@@WIN32_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
|
||||
chr01_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
||||
am__DEPENDENCIES_3 = $(am__DEPENDENCIES_2)
|
||||
@ENABLE_CXX_TRUE@arr01_DEPENDENCIES = $(am__DEPENDENCIES_3)
|
||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||
am__v_lt_0 = --silent
|
||||
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_chr01_OBJECTS = chr01.$(OBJEXT)
|
||||
chr01_OBJECTS = $(am_chr01_OBJECTS)
|
||||
chr01_LDADD = $(LDADD)
|
||||
chr01_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
||||
dir01_SOURCES = dir01.c
|
||||
dir01_OBJECTS = dir01.$(OBJEXT)
|
||||
dir01_LDADD = $(LDADD)
|
||||
@ -139,10 +157,18 @@ am_glob01_OBJECTS = glob01.$(OBJEXT)
|
||||
glob01_OBJECTS = $(am_glob01_OBJECTS)
|
||||
glob01_LDADD = $(LDADD)
|
||||
glob01_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
||||
am_htb_OBJECTS = htb.$(OBJEXT)
|
||||
htb_OBJECTS = $(am_htb_OBJECTS)
|
||||
htb_LDADD = $(LDADD)
|
||||
htb_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
||||
am__hl01_SOURCES_DIST = hl01.cpp
|
||||
@ENABLE_CXX_TRUE@am_hl01_OBJECTS = hl01.$(OBJEXT)
|
||||
hl01_OBJECTS = $(am_hl01_OBJECTS)
|
||||
@ENABLE_CXX_TRUE@hl01_DEPENDENCIES = $(am__DEPENDENCIES_3)
|
||||
am_htb01_OBJECTS = htb01.$(OBJEXT)
|
||||
htb01_OBJECTS = $(am_htb01_OBJECTS)
|
||||
htb01_LDADD = $(LDADD)
|
||||
htb01_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
||||
am__htb02_SOURCES_DIST = htb02.cpp
|
||||
@ENABLE_CXX_TRUE@am_htb02_OBJECTS = htb02.$(OBJEXT)
|
||||
htb02_OBJECTS = $(am_htb02_OBJECTS)
|
||||
@ENABLE_CXX_TRUE@htb02_DEPENDENCIES = $(am__DEPENDENCIES_3)
|
||||
am_ipad01_OBJECTS = ipad01.$(OBJEXT)
|
||||
ipad01_OBJECTS = $(am_ipad01_OBJECTS)
|
||||
ipad01_LDADD = $(LDADD)
|
||||
@ -195,10 +221,18 @@ am_pma_OBJECTS = pma.$(OBJEXT)
|
||||
pma_OBJECTS = $(am_pma_OBJECTS)
|
||||
pma_LDADD = $(LDADD)
|
||||
pma_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
||||
am_rbt_OBJECTS = rbt.$(OBJEXT)
|
||||
rbt_OBJECTS = $(am_rbt_OBJECTS)
|
||||
rbt_LDADD = $(LDADD)
|
||||
rbt_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
||||
am_rbt01_OBJECTS = rbt01.$(OBJEXT)
|
||||
rbt01_OBJECTS = $(am_rbt01_OBJECTS)
|
||||
rbt01_LDADD = $(LDADD)
|
||||
rbt01_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
||||
am__rbt02_SOURCES_DIST = rbt02.cpp
|
||||
@ENABLE_CXX_TRUE@am_rbt02_OBJECTS = rbt02.$(OBJEXT)
|
||||
rbt02_OBJECTS = $(am_rbt02_OBJECTS)
|
||||
@ENABLE_CXX_TRUE@rbt02_DEPENDENCIES = $(am__DEPENDENCIES_3)
|
||||
am__rbt03_SOURCES_DIST = rbt03.cpp
|
||||
@ENABLE_CXX_TRUE@am_rbt03_OBJECTS = rbt03.$(OBJEXT)
|
||||
rbt03_OBJECTS = $(am_rbt03_OBJECTS)
|
||||
@ENABLE_CXX_TRUE@rbt03_DEPENDENCIES = $(am__DEPENDENCIES_3)
|
||||
am_rex01_OBJECTS = rex01.$(OBJEXT)
|
||||
rex01_OBJECTS = $(am_rex01_OBJECTS)
|
||||
rex01_LDADD = $(LDADD)
|
||||
@ -223,6 +257,14 @@ am_slmb01_OBJECTS = slmb01.$(OBJEXT)
|
||||
slmb01_OBJECTS = $(am_slmb01_OBJECTS)
|
||||
slmb01_LDADD = $(LDADD)
|
||||
slmb01_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
||||
am__sp01_SOURCES_DIST = sp01.cpp
|
||||
@ENABLE_CXX_TRUE@am_sp01_OBJECTS = sp01.$(OBJEXT)
|
||||
sp01_OBJECTS = $(am_sp01_OBJECTS)
|
||||
@ENABLE_CXX_TRUE@sp01_DEPENDENCIES = $(am__DEPENDENCIES_3)
|
||||
am__sp02_SOURCES_DIST = sp02.cpp
|
||||
@ENABLE_CXX_TRUE@am_sp02_OBJECTS = sp02.$(OBJEXT)
|
||||
sp02_OBJECTS = $(am_sp02_OBJECTS)
|
||||
@ENABLE_CXX_TRUE@sp02_DEPENDENCIES = $(am__DEPENDENCIES_3)
|
||||
am_str01_OBJECTS = str01.$(OBJEXT)
|
||||
str01_OBJECTS = $(am_str01_OBJECTS)
|
||||
str01_LDADD = $(LDADD)
|
||||
@ -270,32 +312,54 @@ LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
|
||||
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
|
||||
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
AM_V_CXX = $(am__v_CXX_@AM_V@)
|
||||
am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
|
||||
am__v_CXX_0 = @echo " CXX " $@;
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
|
||||
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
|
||||
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
|
||||
am__v_CXXLD_0 = @echo " CXXLD " $@;
|
||||
AM_V_GEN = $(am__v_GEN_@AM_V@)
|
||||
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
SOURCES = $(chr01_SOURCES) dir01.c $(dll_SOURCES) $(env01_SOURCES) \
|
||||
SOURCES = $(arr01_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) \
|
||||
$(rbt01_SOURCES) $(rbt02_SOURCES) $(rbt03_SOURCES) \
|
||||
$(rex01_SOURCES) $(sio01_SOURCES) $(sio02_SOURCES) \
|
||||
$(sio03_SOURCES) $(sll_SOURCES) $(slmb01_SOURCES) \
|
||||
$(sp01_SOURCES) $(sp02_SOURCES) $(str01_SOURCES) task01.c \
|
||||
$(time_SOURCES) $(tre01_SOURCES) uri01.c $(xma_SOURCES)
|
||||
DIST_SOURCES = $(am__arr01_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) $(htb_SOURCES) $(ipad01_SOURCES) \
|
||||
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) $(rbt_SOURCES) $(rex01_SOURCES) \
|
||||
$(sio01_SOURCES) $(sio02_SOURCES) $(sio03_SOURCES) \
|
||||
$(sll_SOURCES) $(slmb01_SOURCES) $(str01_SOURCES) task01.c \
|
||||
$(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) \
|
||||
$(am__sp02_SOURCES_DIST) $(str01_SOURCES) task01.c \
|
||||
$(time_SOURCES) $(tre01_SOURCES) uri01.c $(xma_SOURCES)
|
||||
DIST_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) $(htb_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) $(rbt_SOURCES) \
|
||||
$(rex01_SOURCES) $(sio01_SOURCES) $(sio02_SOURCES) \
|
||||
$(sio03_SOURCES) $(sll_SOURCES) $(slmb01_SOURCES) \
|
||||
$(str01_SOURCES) task01.c $(time_SOURCES) $(tre01_SOURCES) \
|
||||
uri01.c $(xma_SOURCES)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
@ -496,7 +560,7 @@ fmt01_SOURCES = fmt01.c
|
||||
fmt02_SOURCES = fmt02.c
|
||||
fs01_SOURCES = fs01.c
|
||||
glob01_SOURCES = glob01.c
|
||||
htb_SOURCES = htb.c
|
||||
htb01_SOURCES = htb01.c
|
||||
ipad01_SOURCES = ipad01.c
|
||||
lda_SOURCES = lda.c
|
||||
main01_SOURCES = main01.c
|
||||
@ -509,7 +573,7 @@ path01_SOURCES = path01.c
|
||||
pio_SOURCES = pio.c
|
||||
pma_SOURCES = pma.c
|
||||
rex01_SOURCES = rex01.c
|
||||
rbt_SOURCES = rbt.c
|
||||
rbt01_SOURCES = rbt01.c
|
||||
sio01_SOURCES = sio01.c
|
||||
sio02_SOURCES = sio02.c
|
||||
sio03_SOURCES = sio03.c
|
||||
@ -519,10 +583,26 @@ str01_SOURCES = str01.c
|
||||
time_SOURCES = time.c
|
||||
tre01_SOURCES = tre01.c
|
||||
xma_SOURCES = xma.c
|
||||
@ENABLE_CXX_TRUE@arr01_SOURCES = arr01.cpp
|
||||
@ENABLE_CXX_TRUE@arr01_LDADD = $(LDADD) -lqsecmnxx
|
||||
@ENABLE_CXX_TRUE@bh01_SOURCES = bh01.cpp
|
||||
@ENABLE_CXX_TRUE@bh01_LDADD = $(LDADD) -lqsecmnxx
|
||||
@ENABLE_CXX_TRUE@hl01_SOURCES = hl01.cpp
|
||||
@ENABLE_CXX_TRUE@hl01_LDADD = $(LDADD) -lqsecmnxx
|
||||
@ENABLE_CXX_TRUE@htb02_SOURCES = htb02.cpp
|
||||
@ENABLE_CXX_TRUE@htb02_LDADD = $(LDADD) -lqsecmnxx
|
||||
@ENABLE_CXX_TRUE@rbt02_SOURCES = rbt02.cpp #RedBlackTree
|
||||
@ENABLE_CXX_TRUE@rbt02_LDADD = $(LDADD) -lqsecmnxx
|
||||
@ENABLE_CXX_TRUE@rbt03_SOURCES = rbt03.cpp #RedBlackTable
|
||||
@ENABLE_CXX_TRUE@rbt03_LDADD = $(LDADD) -lqsecmnxx
|
||||
@ENABLE_CXX_TRUE@sp01_SOURCES = sp01.cpp # ScopedPtr
|
||||
@ENABLE_CXX_TRUE@sp01_LDADD = $(LDADD) -lqsecmnxx
|
||||
@ENABLE_CXX_TRUE@sp02_SOURCES = sp02.cpp # SharedPtr
|
||||
@ENABLE_CXX_TRUE@sp02_LDADD = $(LDADD) -lqsecmnxx
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
.SUFFIXES: .c .cpp .lo .o .obj
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
@ -599,6 +679,12 @@ clean-binPROGRAMS:
|
||||
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
|
||||
echo " rm -f" $$list; \
|
||||
rm -f $$list
|
||||
arr01$(EXEEXT): $(arr01_OBJECTS) $(arr01_DEPENDENCIES) $(EXTRA_arr01_DEPENDENCIES)
|
||||
@rm -f arr01$(EXEEXT)
|
||||
$(AM_V_CXXLD)$(CXXLINK) $(arr01_OBJECTS) $(arr01_LDADD) $(LIBS)
|
||||
bh01$(EXEEXT): $(bh01_OBJECTS) $(bh01_DEPENDENCIES) $(EXTRA_bh01_DEPENDENCIES)
|
||||
@rm -f bh01$(EXEEXT)
|
||||
$(AM_V_CXXLD)$(CXXLINK) $(bh01_OBJECTS) $(bh01_LDADD) $(LIBS)
|
||||
chr01$(EXEEXT): $(chr01_OBJECTS) $(chr01_DEPENDENCIES) $(EXTRA_chr01_DEPENDENCIES)
|
||||
@rm -f chr01$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(chr01_OBJECTS) $(chr01_LDADD) $(LIBS)
|
||||
@ -638,9 +724,15 @@ fs03$(EXEEXT): $(fs03_OBJECTS) $(fs03_DEPENDENCIES) $(EXTRA_fs03_DEPENDENCIES)
|
||||
glob01$(EXEEXT): $(glob01_OBJECTS) $(glob01_DEPENDENCIES) $(EXTRA_glob01_DEPENDENCIES)
|
||||
@rm -f glob01$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(glob01_OBJECTS) $(glob01_LDADD) $(LIBS)
|
||||
htb$(EXEEXT): $(htb_OBJECTS) $(htb_DEPENDENCIES) $(EXTRA_htb_DEPENDENCIES)
|
||||
@rm -f htb$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(htb_OBJECTS) $(htb_LDADD) $(LIBS)
|
||||
hl01$(EXEEXT): $(hl01_OBJECTS) $(hl01_DEPENDENCIES) $(EXTRA_hl01_DEPENDENCIES)
|
||||
@rm -f hl01$(EXEEXT)
|
||||
$(AM_V_CXXLD)$(CXXLINK) $(hl01_OBJECTS) $(hl01_LDADD) $(LIBS)
|
||||
htb01$(EXEEXT): $(htb01_OBJECTS) $(htb01_DEPENDENCIES) $(EXTRA_htb01_DEPENDENCIES)
|
||||
@rm -f htb01$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(htb01_OBJECTS) $(htb01_LDADD) $(LIBS)
|
||||
htb02$(EXEEXT): $(htb02_OBJECTS) $(htb02_DEPENDENCIES) $(EXTRA_htb02_DEPENDENCIES)
|
||||
@rm -f htb02$(EXEEXT)
|
||||
$(AM_V_CXXLD)$(CXXLINK) $(htb02_OBJECTS) $(htb02_LDADD) $(LIBS)
|
||||
ipad01$(EXEEXT): $(ipad01_OBJECTS) $(ipad01_DEPENDENCIES) $(EXTRA_ipad01_DEPENDENCIES)
|
||||
@rm -f ipad01$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(ipad01_OBJECTS) $(ipad01_LDADD) $(LIBS)
|
||||
@ -680,9 +772,15 @@ pio$(EXEEXT): $(pio_OBJECTS) $(pio_DEPENDENCIES) $(EXTRA_pio_DEPENDENCIES)
|
||||
pma$(EXEEXT): $(pma_OBJECTS) $(pma_DEPENDENCIES) $(EXTRA_pma_DEPENDENCIES)
|
||||
@rm -f pma$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(pma_OBJECTS) $(pma_LDADD) $(LIBS)
|
||||
rbt$(EXEEXT): $(rbt_OBJECTS) $(rbt_DEPENDENCIES) $(EXTRA_rbt_DEPENDENCIES)
|
||||
@rm -f rbt$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(rbt_OBJECTS) $(rbt_LDADD) $(LIBS)
|
||||
rbt01$(EXEEXT): $(rbt01_OBJECTS) $(rbt01_DEPENDENCIES) $(EXTRA_rbt01_DEPENDENCIES)
|
||||
@rm -f rbt01$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(rbt01_OBJECTS) $(rbt01_LDADD) $(LIBS)
|
||||
rbt02$(EXEEXT): $(rbt02_OBJECTS) $(rbt02_DEPENDENCIES) $(EXTRA_rbt02_DEPENDENCIES)
|
||||
@rm -f rbt02$(EXEEXT)
|
||||
$(AM_V_CXXLD)$(CXXLINK) $(rbt02_OBJECTS) $(rbt02_LDADD) $(LIBS)
|
||||
rbt03$(EXEEXT): $(rbt03_OBJECTS) $(rbt03_DEPENDENCIES) $(EXTRA_rbt03_DEPENDENCIES)
|
||||
@rm -f rbt03$(EXEEXT)
|
||||
$(AM_V_CXXLD)$(CXXLINK) $(rbt03_OBJECTS) $(rbt03_LDADD) $(LIBS)
|
||||
rex01$(EXEEXT): $(rex01_OBJECTS) $(rex01_DEPENDENCIES) $(EXTRA_rex01_DEPENDENCIES)
|
||||
@rm -f rex01$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(rex01_OBJECTS) $(rex01_LDADD) $(LIBS)
|
||||
@ -701,6 +799,12 @@ sll$(EXEEXT): $(sll_OBJECTS) $(sll_DEPENDENCIES) $(EXTRA_sll_DEPENDENCIES)
|
||||
slmb01$(EXEEXT): $(slmb01_OBJECTS) $(slmb01_DEPENDENCIES) $(EXTRA_slmb01_DEPENDENCIES)
|
||||
@rm -f slmb01$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(slmb01_OBJECTS) $(slmb01_LDADD) $(LIBS)
|
||||
sp01$(EXEEXT): $(sp01_OBJECTS) $(sp01_DEPENDENCIES) $(EXTRA_sp01_DEPENDENCIES)
|
||||
@rm -f sp01$(EXEEXT)
|
||||
$(AM_V_CXXLD)$(CXXLINK) $(sp01_OBJECTS) $(sp01_LDADD) $(LIBS)
|
||||
sp02$(EXEEXT): $(sp02_OBJECTS) $(sp02_DEPENDENCIES) $(EXTRA_sp02_DEPENDENCIES)
|
||||
@rm -f sp02$(EXEEXT)
|
||||
$(AM_V_CXXLD)$(CXXLINK) $(sp02_OBJECTS) $(sp02_LDADD) $(LIBS)
|
||||
str01$(EXEEXT): $(str01_OBJECTS) $(str01_DEPENDENCIES) $(EXTRA_str01_DEPENDENCIES)
|
||||
@rm -f str01$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(str01_OBJECTS) $(str01_LDADD) $(LIBS)
|
||||
@ -726,6 +830,8 @@ mostlyclean-compile:
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arr01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bh01.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@
|
||||
@ -739,7 +845,9 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs02.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs03.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glob01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htb.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hl01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htb01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htb02.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ipad01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lda.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main01.Po@am__quote@
|
||||
@ -753,13 +861,17 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/path01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pio.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pma.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rbt.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rbt01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rbt02.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rbt03.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rex01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sio01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sio02.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sio03.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sll.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slmb01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sp01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sp02.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/task01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time.Po@am__quote@
|
||||
@ -788,6 +900,27 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
.cpp.o:
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
|
||||
|
||||
.cpp.obj:
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
|
||||
.cpp.lo:
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
@ -1000,11 +1133,6 @@ uninstall-am: uninstall-binPROGRAMS
|
||||
uninstall-binPROGRAMS
|
||||
|
||||
|
||||
#bin_PROGRAMS += rex02
|
||||
#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
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
147
qse/samples/cmn/arr01.cpp
Normal file
147
qse/samples/cmn/arr01.cpp
Normal file
@ -0,0 +1,147 @@
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <qse/cmn/Array.hpp>
|
||||
|
||||
/*
|
||||
typedef QSE::Array<int,int> IntArray;
|
||||
|
||||
struct IntClass
|
||||
{
|
||||
IntClass (int x = 0): x (x) {}
|
||||
int x;
|
||||
};
|
||||
|
||||
struct IntClassComparator
|
||||
{
|
||||
int operator() (const IntClass& v, int y) const
|
||||
{
|
||||
IntTable::DefaultComparator comp;
|
||||
return comp (v.x, y);
|
||||
}
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
#if 1
|
||||
class PosStr: public std::string
|
||||
{
|
||||
public:
|
||||
PosStr (const char* str = ""): std::string(str), pos((qse_size_t)-1) {};
|
||||
|
||||
PosStr (const PosStr& ps): std::string (ps), pos(ps.pos)
|
||||
{
|
||||
}
|
||||
|
||||
~PosStr()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
qse_size_t pos;
|
||||
};
|
||||
#else
|
||||
|
||||
class PosStr
|
||||
{
|
||||
public:
|
||||
PosStr (const char* str = "")
|
||||
{
|
||||
strcpy (buf, str);
|
||||
}
|
||||
|
||||
const char* c_str() const { return this->buf; }
|
||||
const char* data() const { return this->buf; }
|
||||
|
||||
char buf[512];
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
struct cstr_comparator
|
||||
{
|
||||
int operator() (const char* v1, const std::string& v2) const
|
||||
{
|
||||
return strcmp (v1, v2.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef QSE::Array<PosStr> StrArray;
|
||||
|
||||
|
||||
int main ()
|
||||
{
|
||||
//StrArray h (QSE_NULL, 100);
|
||||
StrArray h (QSE_NULL, 15);
|
||||
char buf[20];
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
sprintf (buf, "hello %d", i);
|
||||
PosStr x (buf);
|
||||
h.insert (0, x);
|
||||
}
|
||||
|
||||
#if 0
|
||||
printf ("%s\n", h.get(3).c_str());
|
||||
h.remove (3, 5);
|
||||
printf ("%s\n", h.get(3).c_str());
|
||||
h.remove (3, 5);
|
||||
printf ("%s\n", h.get(3).c_str());
|
||||
#endif
|
||||
printf ("--------------------\n");
|
||||
for (qse_size_t i = 0; i < h.getSize(); i++)
|
||||
{
|
||||
printf ("[%s] at [%lu]\n", h[i].c_str(), (unsigned long int)h.getIndex(h[i]));
|
||||
}
|
||||
printf ("--------------------\n");
|
||||
|
||||
StrArray h2 (h);
|
||||
StrArray h3;
|
||||
|
||||
h3 = h2;
|
||||
h.clear (true);
|
||||
printf ("--------------------\n");
|
||||
printf ("%d\n", (int)h.getSize());
|
||||
printf ("--------------------\n");
|
||||
for (qse_size_t i = 0; i < h2.getSize(); i++)
|
||||
{
|
||||
printf ("[%s] at [%lu]\n", h2[i].c_str(), (unsigned long int)h2.getIndex(h2[i]));
|
||||
}
|
||||
printf ("--------------------\n");
|
||||
|
||||
h3.insert (21, "this is a large string");
|
||||
printf ("%d %d\n", (int)h2.getSize(), (int)h3.getSize());
|
||||
printf ("--------------------\n");
|
||||
h3.insert (21, "mystery!");
|
||||
for (qse_size_t i = 0; i < h3.getSize(); i++)
|
||||
{
|
||||
printf ("[%s] at [%lu]\n", h3[i].c_str(), (unsigned long int)h3.getIndex(h3[i]));
|
||||
}
|
||||
|
||||
printf ("--------------------\n");
|
||||
h3.setCapacity (6);
|
||||
h3.insert (6, "good?");
|
||||
h3.rotate (1, h3.getSize() / 2);
|
||||
printf ("[%s] [%s]\n", h3.getValueAt(5).c_str(), h3.getValueAt(6).c_str());
|
||||
printf ("%d\n", (int)h3.getSize());
|
||||
|
||||
printf ("--------------------\n");
|
||||
h3.insert (1, "bad?");
|
||||
for (qse_size_t i = 0; i < h3.getSize(); i++)
|
||||
{
|
||||
printf ("[%s] at [%lu]\n", h3[i].c_str(), (unsigned long int)h3.getIndex(h3[i]));
|
||||
}
|
||||
|
||||
printf ("--------------------\n");
|
||||
QSE::Array<int> a;
|
||||
a.insert (0, 10);
|
||||
a.insert (0, 20);
|
||||
a.insert (0, 30);
|
||||
const int& t = a[2];
|
||||
printf ("%lu\n", (unsigned long int)a.getIndex(t));
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
224
qse/samples/cmn/bh01.cpp
Normal file
224
qse/samples/cmn/bh01.cpp
Normal file
@ -0,0 +1,224 @@
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <qse/cmn/BinaryHeap.hpp>
|
||||
#include <qse/cmn/LinkedList.hpp>
|
||||
#include <string.h>
|
||||
|
||||
class PosStr: public std::string
|
||||
{
|
||||
public:
|
||||
PosStr (const char* str = ""): std::string(str), heap_pos((qse_size_t)-1) {};
|
||||
|
||||
PosStr (const PosStr& ps): std::string (ps), heap_pos(ps.heap_pos)
|
||||
{
|
||||
}
|
||||
|
||||
~PosStr()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
qse_size_t heap_pos;
|
||||
};
|
||||
|
||||
struct cstr_comparator
|
||||
{
|
||||
bool operator() (const char* v1, const PosStr& v2) const
|
||||
{
|
||||
//return strcmp (v1, v2.c_str()) > 0;
|
||||
return strcmp (v1, v2.c_str()) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct str_comparator
|
||||
{
|
||||
bool operator() (const PosStr& v1, const PosStr& v2) const
|
||||
{
|
||||
//return strcmp (v1.c_str(), v2.c_str()) > 0;
|
||||
return strcmp (v1.c_str(), v2.c_str()) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef QSE::BinaryHeap<PosStr,str_comparator> StrHeap;
|
||||
typedef QSE::LinkedList<PosStr> StrList;
|
||||
|
||||
|
||||
class Container
|
||||
{
|
||||
public:
|
||||
struct str_ptr_greater_than
|
||||
{
|
||||
bool operator() (const StrList::Node* v1, const StrList::Node* v2) const
|
||||
{
|
||||
//return strcmp (v1.c_str(), v2.c_str()) > 0;
|
||||
return strcmp (v1->value.c_str(), v2->value.c_str()) > 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct str_ptr_positioner
|
||||
{
|
||||
void operator() (StrList::Node* v, qse_size_t index) const
|
||||
{
|
||||
v->value.heap_pos = index;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef QSE::BinaryHeap<StrList::Node*,str_ptr_greater_than,str_ptr_positioner> StrPtrHeap;
|
||||
|
||||
StrList::Node* insert (const char* str)
|
||||
{
|
||||
StrList::Node* node = this->str_list.append (PosStr(str));
|
||||
qse_size_t heap_pos = this->str_heap.insert (node);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
bool isEmpty () const
|
||||
{
|
||||
QSE_ASSERT (this->str_list.isEmpty() == this->str_heap.isEmpty());
|
||||
return this->str_list.isEmpty();
|
||||
}
|
||||
|
||||
qse_size_t getSize() const
|
||||
{
|
||||
QSE_ASSERT (this->str_list.getSize() == this->str_heap.getSize());
|
||||
return this->str_list.getSize();
|
||||
}
|
||||
|
||||
const PosStr& getLargest () const
|
||||
{
|
||||
StrList::Node* node = this->str_heap.getValueAt(0);
|
||||
return node->value;
|
||||
}
|
||||
|
||||
void removeLargest ()
|
||||
{
|
||||
StrList::Node* node = this->str_heap.getValueAt(0);
|
||||
this->str_heap.remove (0);
|
||||
this->str_list.remove (node);
|
||||
}
|
||||
|
||||
void remove (StrList::Node* node)
|
||||
{
|
||||
this->str_heap.remove (node->value.heap_pos);
|
||||
this->str_list.remove (node);
|
||||
}
|
||||
|
||||
StrList::Node* getHeapValueAt (qse_size_t index)
|
||||
{
|
||||
return this->str_heap.getValueAt(index);
|
||||
}
|
||||
|
||||
|
||||
StrList str_list;
|
||||
StrPtrHeap str_heap;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct IntComparator
|
||||
{
|
||||
bool operator() (int v1, int v2) const
|
||||
{
|
||||
//return !(v1 > v2);
|
||||
//return v1 > v2;
|
||||
return v1 < v2;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main ()
|
||||
{
|
||||
char buf[20];
|
||||
StrHeap h;
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
sprintf (buf, "hello %d", i);
|
||||
h.insert (buf);
|
||||
h.insert (buf);
|
||||
}
|
||||
|
||||
for (int i = 0; i < h.getSize(); i++)
|
||||
{
|
||||
printf ("%05d %s\n", (int)h.getIndex(h[i]), h[i].c_str());
|
||||
}
|
||||
printf ("----------------\n");
|
||||
|
||||
|
||||
while (!h.isEmpty())
|
||||
{
|
||||
printf ("%s\n", h[0].c_str());
|
||||
h.remove (0);
|
||||
}
|
||||
printf ("----------------\n");
|
||||
{
|
||||
|
||||
QSE::BinaryHeap<int,IntComparator> h2;
|
||||
|
||||
h2.insert (70);
|
||||
h2.insert (90);
|
||||
h2.insert (10);
|
||||
h2.insert (5);
|
||||
h2.insert (88);
|
||||
h2.insert (87);
|
||||
h2.insert (300);
|
||||
h2.insert (91);
|
||||
h2.insert (100);
|
||||
h2.insert (200);
|
||||
|
||||
while (h2.getSize() > 0)
|
||||
{
|
||||
printf ("%d\n", h2.getValueAt(0));
|
||||
h2.remove (0);
|
||||
}
|
||||
}
|
||||
|
||||
printf ("----------------\n");
|
||||
|
||||
{
|
||||
Container c;
|
||||
StrList::Node* node2, * node14;
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
sprintf (buf, "hello %d", i);
|
||||
|
||||
//c.insert (buf);
|
||||
|
||||
if (i == 2)
|
||||
{
|
||||
node2 = c.insert (buf);
|
||||
printf ("2nd => %s\n", node2->value.c_str());
|
||||
}
|
||||
else if (i == 14)
|
||||
{
|
||||
node14 = c.insert (buf);
|
||||
printf ("14th => %s\n", node14->value.c_str());
|
||||
}
|
||||
else c.insert (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
for (int i = 0; i < c.getSize(); i++)
|
||||
{
|
||||
StrList::Node* node = c.getHeapValueAt(i);
|
||||
|
||||
printf ("%s %d\n", node->value.c_str(), (int)node->value.heap_pos);
|
||||
}
|
||||
*/
|
||||
|
||||
for (int i = 0; c.getSize() > 0; i++)
|
||||
{
|
||||
if (i == 3) c.remove (node2);
|
||||
if (i == 5) c.remove (node14);
|
||||
|
||||
const char* largest = c.getLargest().c_str();
|
||||
printf ("%s\n", largest);
|
||||
c.removeLargest ();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#include <qse/cmn/chr.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
@ -47,7 +47,12 @@ int main ()
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
|
||||
|
||||
qse_openstdsios ();
|
||||
|
||||
R (test1);
|
||||
|
||||
qse_closestdsios ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <qse/cmn/fio.h>
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
@ -300,6 +300,7 @@ static int test3 (void)
|
||||
|
||||
int main ()
|
||||
{
|
||||
qse_openstdsios ();
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
@ -314,5 +315,6 @@ int main ()
|
||||
qse_printf (QSE_T("Run \"rm -f fio01-?.txt\" to delete garbages\n"));
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
|
||||
qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <qse/cmn/fio.h>
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#define R(f) \
|
||||
do { \
|
||||
@ -79,6 +79,8 @@ static int test1 (void)
|
||||
|
||||
int main ()
|
||||
{
|
||||
qse_openstdsios();
|
||||
R (test1);
|
||||
qse_closestdsios();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <qse/cmn/fma.h>
|
||||
#include <qse/cmn/rbt.h>
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#define R(f) \
|
||||
do { \
|
||||
@ -28,16 +28,21 @@ static int test1 ()
|
||||
int i;
|
||||
int* ptr[100];
|
||||
|
||||
qse_fma_t* fma = qse_fma_open (QSE_MMGR_GETDFL(), 0, sizeof(int), 10, 5);
|
||||
qse_fma_t* fma = qse_fma_open (QSE_MMGR_GETDFL(), 0, sizeof(int), 10 /* max block size */, 5 /* max chunks */);
|
||||
if (fma == QSE_NULL)
|
||||
{
|
||||
qse_printf (QSE_T("cannot open fma\n"));
|
||||
return -1;
|
||||
}
|
||||
/* max 50 (10 * 5) allocations should be possible */
|
||||
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
ptr[i] = qse_fma_alloc (fma, sizeof(int));
|
||||
|
||||
if (i < 50) QSE_ASSERT (ptr[i] != QSE_NULL);
|
||||
else QSE_ASSERT (ptr[i] == QSE_NULL);
|
||||
|
||||
if (ptr[i])
|
||||
{
|
||||
qse_printf (QSE_T("%d %p\n"), i, ptr[i]);
|
||||
@ -67,6 +72,9 @@ static int test1 ()
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
ptr[i] = qse_fma_alloc (fma, sizeof(int));
|
||||
if (i < 50) QSE_ASSERT (ptr[i] != QSE_NULL);
|
||||
else QSE_ASSERT (ptr[i] == QSE_NULL);
|
||||
|
||||
if (ptr[i])
|
||||
{
|
||||
qse_printf (QSE_T("%d %p\n"), i, ptr[i]);
|
||||
@ -79,6 +87,21 @@ static int test1 ()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void* fma_alloc (qse_mmgr_t* mmgr, qse_size_t size)
|
||||
{
|
||||
return qse_fma_alloc (mmgr->ctx, size);
|
||||
}
|
||||
|
||||
static void* fma_realloc (qse_mmgr_t* mmgr, void* ptr, qse_size_t size)
|
||||
{
|
||||
return qse_fma_realloc (mmgr->ctx, ptr, size);
|
||||
}
|
||||
|
||||
static void fma_free (qse_mmgr_t* mmgr, void* ptr)
|
||||
{
|
||||
qse_fma_free (mmgr->ctx, ptr);
|
||||
}
|
||||
|
||||
static qse_rbt_walk_t walk (qse_rbt_t* rbt, qse_rbt_pair_t* pair, void* ctx)
|
||||
{
|
||||
qse_printf (QSE_T("key = %lld, value = %lld\n"),
|
||||
@ -90,9 +113,9 @@ static int test2 ()
|
||||
{
|
||||
qse_mmgr_t mmgr =
|
||||
{
|
||||
(qse_mmgr_alloc_t) qse_fma_alloc,
|
||||
(qse_mmgr_realloc_t) qse_fma_realloc,
|
||||
(qse_mmgr_free_t) qse_fma_free,
|
||||
fma_alloc,
|
||||
fma_realloc,
|
||||
fma_free,
|
||||
QSE_NULL
|
||||
};
|
||||
qse_fma_t* fma;
|
||||
@ -111,22 +134,46 @@ static int test2 ()
|
||||
}
|
||||
|
||||
mmgr.ctx = fma;
|
||||
if (qse_rbt_init (&rbt, &mmgr, QSE_SIZEOF(long), QSE_SIZEOF(long)) == QSE_NULL)
|
||||
if (qse_rbt_init (&rbt, &mmgr, QSE_SIZEOF(long int), QSE_SIZEOF(long int)) <= -1)
|
||||
{
|
||||
qse_printf (QSE_T("cannot initialize a tree\n"));
|
||||
qse_fma_close (fma);
|
||||
return -1;
|
||||
}
|
||||
|
||||
qse_rbt_setstyle (&rbt, &style);
|
||||
|
||||
|
||||
for (x = 10; x < 100; x++)
|
||||
{
|
||||
long y = x * x;
|
||||
long int y = x * x;
|
||||
|
||||
if (qse_rbt_insert (&rbt, &x, 1, &y, 1) == QSE_NULL)
|
||||
{
|
||||
qse_printf (QSE_T("failed to insert. out of memory\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
for (x = 10; x < 105; x++)
|
||||
{
|
||||
long int y = x * x, yy;
|
||||
qse_rbt_pair_t* pair;
|
||||
|
||||
pair = qse_rbt_search (&rbt, &x, 1);
|
||||
if (x < 100)
|
||||
{
|
||||
QSE_ASSERT (pair != QSE_NULL);
|
||||
yy = *(long int*)QSE_RBT_VPTR(pair);
|
||||
QSE_ASSERT (yy = y);
|
||||
qse_printf (QSE_T("%ld => %ld\n"), (long int)x, (long int)yy);
|
||||
}
|
||||
else
|
||||
{
|
||||
QSE_ASSERT (pair == QSE_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
qse_rbt_walk (&rbt, walk, QSE_NULL);
|
||||
@ -139,7 +186,9 @@ static int test2 ()
|
||||
|
||||
int main ()
|
||||
{
|
||||
qse_openstdsios ();
|
||||
R (test1);
|
||||
R (test2);
|
||||
qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <qse/cmn/fmt.h>
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
#if defined(_WIN32)
|
||||
@ -56,9 +56,11 @@ static int test_main (int argc, qse_char_t* argv[])
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
int x;
|
||||
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
@ -66,14 +68,17 @@ int qse_main (int argc, qse_achar_t* argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
return qse_runmain (argc, argv, test_main);
|
||||
qse_openstdsios ();
|
||||
x = qse_runmain (argc, argv, test_main);
|
||||
qse_closestdsios ();
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <qse/cmn/fmt.h>
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
#if defined(_WIN32)
|
||||
@ -76,9 +76,11 @@ static int test_main (int argc, qse_char_t* argv[])
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
int x;
|
||||
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
@ -91,9 +93,12 @@ int qse_main (int argc, qse_achar_t* argv[])
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
return qse_runmain (argc, argv, test_main);
|
||||
qse_openstdsios ();
|
||||
x = qse_runmain (argc, argv, test_main);
|
||||
qse_closestdsios ();
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
#if defined(_WIN32)
|
||||
@ -75,9 +75,11 @@ int fs_main (int argc, qse_char_t* argv[])
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
int x;
|
||||
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
@ -85,14 +87,21 @@ int qse_main (int argc, qse_achar_t* argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
return qse_runmain (argc, argv, fs_main);
|
||||
|
||||
qse_openstdsios ();
|
||||
|
||||
x = qse_runmain (argc, argv, fs_main);
|
||||
|
||||
qse_closestdsios ();
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
148
qse/samples/cmn/hl01.cpp
Normal file
148
qse/samples/cmn/hl01.cpp
Normal file
@ -0,0 +1,148 @@
|
||||
#include <stdio.h>
|
||||
#include <qse/cmn/StdMmgr.hpp>
|
||||
#include <qse/cmn/HeapMmgr.hpp>
|
||||
#include <qse/cmn/LinkedList.hpp>
|
||||
#include <qse/cmn/HashList.hpp>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
|
||||
class T
|
||||
{
|
||||
public:
|
||||
T(int x = 0): x(x) {
|
||||
// printf ("constructor\n");
|
||||
y = x + 99;
|
||||
}
|
||||
~T() {
|
||||
// printf ("destructor\n");
|
||||
}
|
||||
bool operator== (const T& x) const { return this->x == x.x; }
|
||||
qse_size_t hashCode() const { return x; }
|
||||
|
||||
int getValue() const { return this->x; }
|
||||
int getY() const { return this->y; }
|
||||
protected:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
void* operator new (size_t x, int q)
|
||||
{
|
||||
return ::operator new (x);
|
||||
}
|
||||
|
||||
|
||||
struct IntHasher
|
||||
{
|
||||
qse_size_t operator() (int v) const { return v; }
|
||||
};
|
||||
|
||||
struct IntIsEqual
|
||||
{
|
||||
qse_size_t operator() (int v1, const T& v2) const { return v1 == v2.getValue(); }
|
||||
};
|
||||
|
||||
typedef QSE::HashList<int,IntHasher> IntList;
|
||||
|
||||
int main ()
|
||||
{
|
||||
qse_openstdsios ();
|
||||
|
||||
T* x;
|
||||
//QSE::StdMmgr* mmgr = QSE::StdMmgr::getDFL();
|
||||
//QSE::HeapMmgr heap_mmgr (QSE::Mmgr::getDFL(), 1000000);
|
||||
//QSE::Mmgr* mmgr = &heap_mmgr;
|
||||
QSE::Mmgr* mmgr = QSE_NULL;
|
||||
|
||||
/*
|
||||
x = new(mmgr) T; //[10];
|
||||
|
||||
printf ("x====> %p\n", x);
|
||||
x->~T();
|
||||
//for (int i = 0; i < 10; i++) x[i].~T();
|
||||
//::operator delete[] (x, mmgr);
|
||||
::operator delete (x, mmgr);
|
||||
//delete[] x;
|
||||
|
||||
printf ("----------------------\n");
|
||||
T* y = new(10) T;
|
||||
y->~T();
|
||||
::operator delete(y);
|
||||
printf ("----------------------\n");
|
||||
*/
|
||||
try
|
||||
{
|
||||
|
||||
T t1,t2,t3;
|
||||
|
||||
#if 0
|
||||
printf ("----------------------\n");
|
||||
{
|
||||
QSE::LinkedList<T> l (mmgr, 100);
|
||||
printf ("----------------------\n");
|
||||
l.append (t1);
|
||||
printf ("----------------------\n");
|
||||
l.append (t2);
|
||||
l.append (t3);
|
||||
printf ("================\n");
|
||||
|
||||
QSE::LinkedList<T> l2 (mmgr, 100);
|
||||
|
||||
l2 = l;
|
||||
}
|
||||
printf ("----------------------\n");
|
||||
#endif
|
||||
|
||||
//QSE::HashList<T> h (mmgr, 1000, 75, 1000);
|
||||
QSE::HashList<T> h (mmgr, 1000, 75, 500);
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
T x(i);
|
||||
h.insert (x);
|
||||
}
|
||||
printf ("h.getSize() => %d\n", (int)h.getSize());
|
||||
|
||||
QSE::HashList<T> h2 (mmgr, 1000, 75, 700);
|
||||
h2 = h;
|
||||
|
||||
for (QSE::HashList<T>::Iterator it = h2.getIterator(); it.isLegit(); it++)
|
||||
{
|
||||
printf ("%d\n", (*it).getValue());
|
||||
}
|
||||
printf ("----------------------\n");
|
||||
|
||||
|
||||
printf ("%p\n", h2.getHeadNode());
|
||||
printf ("----------------------\n");
|
||||
|
||||
IntList hl;
|
||||
IntList::Iterator it;
|
||||
hl.insert (10);
|
||||
hl.insert (150);
|
||||
hl.insert (200);
|
||||
for (it = hl.getIterator(); it.isLegit(); it++)
|
||||
{
|
||||
printf ("%d\n", *it);
|
||||
}
|
||||
|
||||
|
||||
printf ("----------------------\n");
|
||||
|
||||
{
|
||||
const QSE::HashList<T>& h3 = h2;
|
||||
const T* tt = h3.heterofindValue<int,IntHasher,IntIsEqual> (100);
|
||||
if (tt) printf ("%d:%d\n", tt->getValue(), tt->getY());
|
||||
else printf ("not found...\n");
|
||||
}
|
||||
printf ("----------------------\n");
|
||||
}
|
||||
catch (QSE::Exception& e)
|
||||
{
|
||||
qse_printf (QSE_T("Exception: %s\n"), QSE_EXCEPTION_NAME(e));
|
||||
}
|
||||
|
||||
|
||||
qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <qse/cmn/chr.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/htb.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#define R(f) \
|
||||
do { \
|
||||
@ -402,7 +402,7 @@ static int test5 ()
|
||||
qse_printf (QSE_T("[FAILED]\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
qse_printf (QSE_T("[OK]\n"));
|
||||
}
|
||||
}
|
||||
@ -415,6 +415,7 @@ static int test5 ()
|
||||
|
||||
int main ()
|
||||
{
|
||||
qse_openstdsios ();
|
||||
R (test1);
|
||||
R (test2);
|
||||
#if 0
|
||||
@ -422,5 +423,6 @@ int main ()
|
||||
R (test4);
|
||||
#endif
|
||||
R (test5);
|
||||
qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
221
qse/samples/cmn/htb02.cpp
Normal file
221
qse/samples/cmn/htb02.cpp
Normal file
@ -0,0 +1,221 @@
|
||||
#include <stdio.h>
|
||||
#include <qse/cmn/StdMmgr.hpp>
|
||||
#include <qse/cmn/HeapMmgr.hpp>
|
||||
#include <qse/cmn/HashTable.hpp>
|
||||
#include <qse/cmn/sio.h>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
|
||||
struct IntHasher
|
||||
{
|
||||
qse_size_t operator() (int v) const
|
||||
{
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
typedef QSE::HashTable<int,int,IntHasher> IntTable;
|
||||
|
||||
struct IntClass
|
||||
{
|
||||
IntClass (int x = 0): x (x) {}
|
||||
int x;
|
||||
};
|
||||
|
||||
struct IntClassHasher
|
||||
{
|
||||
qse_size_t operator() (const IntClass& v) const
|
||||
{
|
||||
return v.x;
|
||||
}
|
||||
};
|
||||
|
||||
struct IntClassComparator
|
||||
{
|
||||
bool operator() (const IntClass& v, int y) const
|
||||
{
|
||||
return v.x == y;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct StrHasher
|
||||
{
|
||||
qse_size_t operator() (const std::string& v) const
|
||||
{
|
||||
return QSE::Hashable::getHashCode (v.c_str(), v.length());
|
||||
}
|
||||
};
|
||||
|
||||
typedef QSE::HashTable<std::string,int,StrHasher> Str1Table;
|
||||
|
||||
struct cstr_hasher
|
||||
{
|
||||
qse_size_t operator() (const char* v) const
|
||||
{
|
||||
return QSE::Hashable::getHashCode (v, strlen(v));
|
||||
}
|
||||
};
|
||||
|
||||
struct cstr_is_equal
|
||||
{
|
||||
int operator() (const char* v1, const std::string& v2) const
|
||||
{
|
||||
return strcmp (v1, v2.c_str()) == 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main ()
|
||||
{
|
||||
// qse_openstdsios ();
|
||||
|
||||
QSE::HeapMmgr heap_mmgr (QSE::Mmgr::getDFL(), 3000000);
|
||||
//QSE::HashTable<int,int,IntHasher> int_table (&heap_mmgr, 1000);
|
||||
IntTable int_table (NULL, IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 1000);
|
||||
//IntTable int_table (NULL, IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 0);
|
||||
printf ("----------\n");
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
int_table.insert (i, i * 20);
|
||||
}
|
||||
for (int i = 50; i < 150; i++)
|
||||
{
|
||||
int_table.upsert (i, i * 20);
|
||||
}
|
||||
printf ("----------\n");
|
||||
|
||||
/*
|
||||
qse_size_t bucket_size = int_table.getBucketSize();
|
||||
for (qse_size_t i = 0; i < bucket_size; i++)
|
||||
{
|
||||
IntTable::Bucket* b = int_table.getBucket (i);
|
||||
}
|
||||
*/
|
||||
printf ("----------\n");
|
||||
|
||||
/*
|
||||
IntTable::Pair* pair = int_table.findPairWithCustomKey<IntClass,IntClassHasher,IntClassComparator> (IntClass(50));
|
||||
if (pair)
|
||||
{
|
||||
printf ("pair found.... [%d]\n", pair->value);
|
||||
}
|
||||
*/
|
||||
|
||||
printf ("%p %p\n", int_table.search (60), int_table.search (90));
|
||||
printf ("%d %d\n", int_table.remove (60), int_table.remove (60));
|
||||
printf ("%d %d\n", int_table.remove (70), int_table.remove (70));
|
||||
|
||||
/*
|
||||
printf ("%d\n", int_table[90]);
|
||||
printf ("%d\n", int_table[9990]);
|
||||
*/
|
||||
|
||||
//Str1Table s1 (NULL, IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 1000);
|
||||
Str1Table s1 (NULL, IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 0);
|
||||
//Str1Table s1;
|
||||
s1.insert ("hello", 20);
|
||||
s1.insert ("hello", 20);
|
||||
s1.insert ("hello kara", 20);
|
||||
|
||||
s1.insert ("this is good", 3896);
|
||||
printf ("remove = %d\n", s1.remove ("hello"));
|
||||
printf ("remove = %d\n", s1.remove ("hello"));
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
char buf[128];
|
||||
sprintf (buf, "surukaaaa %d", i);
|
||||
s1.insert (buf, i * 2);
|
||||
}
|
||||
|
||||
printf ("%d\n", (int)s1.getSize());
|
||||
for (Str1Table::Iterator it = s1.getIterator(); it.isLegit(); it++)
|
||||
{
|
||||
Str1Table::Pair& pair = *it;
|
||||
printf ("[%s] [%d]\n", pair.key.c_str(), pair.value);
|
||||
}
|
||||
|
||||
|
||||
printf ("------------------\n");
|
||||
{
|
||||
Str1Table s11 (s1);
|
||||
for (Str1Table::Iterator it = s11.getIterator(); it.isLegit(); it++)
|
||||
{
|
||||
Str1Table::Pair& pair = *it;
|
||||
printf ("[%s] [%d]\n", pair.key.c_str(), pair.value);
|
||||
}
|
||||
}
|
||||
|
||||
printf ("------------------\n");
|
||||
{
|
||||
Str1Table s11 (&heap_mmgr, IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 0);
|
||||
//Str1Table s11 (NULL, IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 200);
|
||||
//Str1Table s11;
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
char buf[128];
|
||||
sprintf (buf, "abiyo %d", i);
|
||||
s11.insert (buf, i * 2);
|
||||
}
|
||||
printf ("%d\n", s11.heteroremove<const char*, cstr_hasher, cstr_is_equal> ("abiyo 12"));
|
||||
printf ("%d\n", s11.heteroremove<const char*, cstr_hasher, cstr_is_equal> ("abiyo 12"));
|
||||
printf ("SIZE => %d\n", (int)s11.getSize());
|
||||
for (Str1Table::Iterator it = s11.getIterator(); it.isLegit(); it++)
|
||||
{
|
||||
Str1Table::Pair& pair = *it;
|
||||
printf ("[%s] [%d]\n", pair.key.c_str(), pair.value);
|
||||
}
|
||||
printf ("------------------\n");
|
||||
|
||||
//s11.clear (true);
|
||||
|
||||
s11 = s1;
|
||||
printf ("SIZE => %d\n", (int)s11.getSize());
|
||||
for (Str1Table::Iterator it = s11.getIterator(); it.isLegit(); it++)
|
||||
{
|
||||
Str1Table::Pair& pair = *it;
|
||||
printf ("[%s] [%d]\n", pair.key.c_str(), pair.value);
|
||||
}
|
||||
|
||||
|
||||
printf ("-------------------\n");
|
||||
Str1Table::Pair* pair = s11.heterosearch<const char*, cstr_hasher, cstr_is_equal> ("surukaaaa 13");
|
||||
if (pair) printf ("%d\n", pair->value);
|
||||
else printf ("not found\n");
|
||||
|
||||
s11.update ("surukaaaa 13", 999);
|
||||
s11.update ("surukaaaa 16", 99999);
|
||||
s11.inject ("surukaaaa 18", 999999, 1);
|
||||
|
||||
pair = s11.heterosearch<const char*, cstr_hasher, cstr_is_equal> ("surukaaaa 13");
|
||||
if (pair) printf ("%d\n", pair->value);
|
||||
else printf ("not found\n");
|
||||
|
||||
|
||||
s1 = s11;
|
||||
}
|
||||
|
||||
printf ("-------------------\n");
|
||||
printf ("%d %d\n", (int)s1.getSize(), (int)s1.getCapacity());
|
||||
for (Str1Table::ConstIterator it = s1.getConstIterator(); it.isLegit(); it++)
|
||||
{
|
||||
const Str1Table::Pair& pair = *it;
|
||||
printf ("[%s] [%d]\n", pair.key.c_str(), pair.value);
|
||||
}
|
||||
|
||||
printf ("-------------------\n");
|
||||
|
||||
for (Str1Table::PairNode* np = s1.getTailNode(); np; np = np->getPrevNode())
|
||||
{
|
||||
Str1Table::Pair& pair = np->value;
|
||||
printf ("[%s] [%d]\n", pair.key.c_str(), pair.value);
|
||||
}
|
||||
|
||||
|
||||
// qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <qse/cmn/ipad.h>
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
#if defined(_WIN32)
|
||||
@ -188,9 +188,10 @@ static int test_main (int argc, qse_char_t* argv[])
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
int x;
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
@ -198,14 +199,17 @@ int qse_main (int argc, qse_achar_t* argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
return qse_runmain (argc, argv, test_main);
|
||||
qse_openstdsios ();
|
||||
x = qse_runmain (argc, argv, test_main);
|
||||
qse_closestdsios ();
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/lda.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
@ -451,10 +451,12 @@ static int test5 ()
|
||||
|
||||
int main ()
|
||||
{
|
||||
qse_openstdsios ();
|
||||
R (test1);
|
||||
R (test2);
|
||||
R (test3);
|
||||
R (test4);
|
||||
R (test5);
|
||||
qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
@ -22,9 +22,11 @@ static int test_main (int argc, qse_char_t* argv[])
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
int x;
|
||||
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
@ -37,10 +39,13 @@ int qse_main (int argc, qse_achar_t* argv[])
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
|
||||
return qse_runmain (argc, argv, test_main);
|
||||
qse_openstdsios ();
|
||||
x = qse_runmain (argc, argv, test_main);
|
||||
qse_closestdsios ();
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
@ -27,9 +27,11 @@ static int test_main (int argc, qse_char_t* argv[], qse_char_t* envp[])
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[], qse_achar_t* envp[])
|
||||
{
|
||||
int x;
|
||||
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
@ -37,15 +39,18 @@ int qse_main (int argc, qse_achar_t* argv[], qse_achar_t* envp[])
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
|
||||
return qse_runmainwithenv (argc, argv, envp, test_main);
|
||||
qse_openstdsios ();
|
||||
x = qse_runmainwithenv (argc, argv, envp, test_main);
|
||||
qse_closestdsios ();
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
@ -215,7 +214,7 @@ int main ()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
@ -224,7 +223,7 @@ int main ()
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
@ -232,6 +231,8 @@ int main ()
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
|
||||
qse_openstdsios ();
|
||||
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
qse_printf (QSE_T("Set the environment LANG to a Unicode locale such as UTF-8 if you see the illegal XXXXX errors. If you see such errors in Unicode locales, this program might be buggy. It is normal to see such messages in non-Unicode locales as it uses Unicode data\n"));
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
@ -241,5 +242,6 @@ int main ()
|
||||
R (test3);
|
||||
R (test4);
|
||||
|
||||
qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
@ -295,7 +294,7 @@ int main ()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
@ -312,6 +311,7 @@ int main ()
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
|
||||
qse_openstdsios ();
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
qse_printf (QSE_T("Set the environment LANG to a Unicode locale such as UTF-8 if you see the illegal XXXXX errors. If you see such errors in Unicode locales, this program might be buggy. It is normal to see such messages in non-Unicode locales as it uses Unicode data\n"));
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
@ -321,5 +321,6 @@ int main ()
|
||||
R (test3);
|
||||
R (test4);
|
||||
|
||||
qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <qse/cmn/nwad.h>
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
#if defined(_WIN32)
|
||||
@ -154,9 +154,10 @@ static int test_main (int argc, qse_char_t* argv[])
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
int x;
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
@ -164,14 +165,17 @@ int qse_main (int argc, qse_achar_t* argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
return qse_runmain (argc, argv, test_main);
|
||||
qse_openstdsios ();
|
||||
x = qse_runmain (argc, argv, test_main);
|
||||
qse_closestdsios ();
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/oht.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
|
||||
#define R(f) \
|
||||
@ -123,7 +123,9 @@ static int test2 ()
|
||||
|
||||
int main ()
|
||||
{
|
||||
qse_openstdsios ();
|
||||
R (test1);
|
||||
R (test2);
|
||||
qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <qse/cmn/pio.h>
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/env.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
@ -395,6 +395,7 @@ static int test13 (void)
|
||||
|
||||
int main ()
|
||||
{
|
||||
qse_openstdsios ();
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
@ -414,6 +415,6 @@ int main ()
|
||||
R (test11);
|
||||
R (test12);
|
||||
R (test13);
|
||||
|
||||
qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <qse/cmn/pma.h>
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#define R(f) \
|
||||
do { \
|
||||
@ -88,7 +88,9 @@ static int test2 ()
|
||||
|
||||
int main ()
|
||||
{
|
||||
qse_openstdsios ();
|
||||
R (test1);
|
||||
R (test2);
|
||||
qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/rbt.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
@ -223,8 +223,10 @@ static int test5 ()
|
||||
|
||||
int main ()
|
||||
{
|
||||
qse_openstdsios ();
|
||||
R (test1);
|
||||
R (test2);
|
||||
R (test5);
|
||||
qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
64
qse/samples/cmn/rbt02.cpp
Normal file
64
qse/samples/cmn/rbt02.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include <stdio.h>
|
||||
#include <qse/cmn/RedBlackTree.hpp>
|
||||
|
||||
class IntPair
|
||||
{
|
||||
public:
|
||||
IntPair (int x = 0, int y = 0): x (x), y (y) {}
|
||||
|
||||
int getX () const { return this->x; }
|
||||
int getY () const { return this->y; }
|
||||
|
||||
bool operator== (const IntPair& ip) const { return this->x == ip.x; }
|
||||
bool operator< (const IntPair& ip) const { return this->x < ip.x; }
|
||||
bool operator> (const IntPair& ip) const { return this->x > ip.x; }
|
||||
|
||||
protected:
|
||||
int x, y;
|
||||
};
|
||||
|
||||
typedef QSE::RedBlackTree<IntPair> IntTree;
|
||||
|
||||
int main ()
|
||||
{
|
||||
|
||||
IntTree t (0, 10000);
|
||||
//IntTree t (0);
|
||||
|
||||
for (int i = 0; i < 20 ; i++)
|
||||
{
|
||||
t.insert (IntPair (i , i * 2));
|
||||
}
|
||||
t.clear (true);
|
||||
for (int i = 0; i < 20 ; i++)
|
||||
{
|
||||
t.insert (IntPair (i , i * 2));
|
||||
}
|
||||
|
||||
IntTree::ConstIterator it;
|
||||
for (it = t.getConstIterator(); it.isLegit(); ++it)
|
||||
{
|
||||
printf ("%d %d\n", it.getValue().getX(), (*it).getY());
|
||||
}
|
||||
|
||||
|
||||
printf ("------------------\n");
|
||||
IntTree x(t);
|
||||
for (it = t.getConstIterator(); it.isLegit(); ++it)
|
||||
{
|
||||
printf ("%d %d\n", it.getValue().getX(), (*it).getY());
|
||||
}
|
||||
|
||||
|
||||
|
||||
printf ("------------------\n");
|
||||
t.insert (IntPair(99, 999));
|
||||
t.insert (IntPair(88, 888));
|
||||
//IntTree y (QSE_NULL, 5);
|
||||
x = t;
|
||||
for (it = x.getConstIterator(); it.isLegit(); ++it)
|
||||
{
|
||||
printf ("%d %d\n", it.getValue().getX(), (*it).getY());
|
||||
}
|
||||
return 0;
|
||||
}
|
191
qse/samples/cmn/rbt03.cpp
Normal file
191
qse/samples/cmn/rbt03.cpp
Normal file
@ -0,0 +1,191 @@
|
||||
#include <stdio.h>
|
||||
#include <qse/cmn/StdMmgr.hpp>
|
||||
#include <qse/cmn/HeapMmgr.hpp>
|
||||
#include <qse/cmn/RedBlackTable.hpp>
|
||||
#include <qse/cmn/sio.h>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
|
||||
typedef QSE::RedBlackTable<int,int> IntTable;
|
||||
|
||||
struct IntClass
|
||||
{
|
||||
IntClass (int x = 0): x (x) {}
|
||||
int x;
|
||||
};
|
||||
|
||||
struct IntClassComparator
|
||||
{
|
||||
int operator() (const IntClass& v, int y) const
|
||||
{
|
||||
IntTable::DefaultComparator comp;
|
||||
return comp (v.x, y);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef QSE::RedBlackTable<std::string,int> Str1Table;
|
||||
|
||||
struct cstr_comparator
|
||||
{
|
||||
int operator() (const char* v1, const std::string& v2) const
|
||||
{
|
||||
return strcmp (v1, v2.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main ()
|
||||
{
|
||||
// qse_openstdsios ();
|
||||
|
||||
QSE::HeapMmgr heap_mmgr (QSE::Mmgr::getDFL(), 3000000);
|
||||
//QSE::RedBlackTable<int,int,IntHasher> int_table (&heap_mmgr, 1000);
|
||||
IntTable int_table (NULL, 1000);
|
||||
//IntTable int_table (NULL, 0);
|
||||
printf ("----------\n");
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
int_table.insert (i, i * 20);
|
||||
}
|
||||
for (int i = 50; i < 150; i++)
|
||||
{
|
||||
int_table.upsert (i, i * 20);
|
||||
}
|
||||
printf ("----------\n");
|
||||
|
||||
/*
|
||||
qse_size_t bucket_size = int_table.getBucketSize();
|
||||
for (qse_size_t i = 0; i < bucket_size; i++)
|
||||
{
|
||||
IntTable::Bucket* b = int_table.getBucket (i);
|
||||
}
|
||||
*/
|
||||
printf ("----------\n");
|
||||
|
||||
/*
|
||||
IntTable::Pair* pair = int_table.findPairWithCustomKey<IntClass,IntClassHasher,IntClassComparator> (IntClass(50));
|
||||
if (pair)
|
||||
{
|
||||
printf ("pair found.... [%d]\n", pair->value);
|
||||
}
|
||||
*/
|
||||
|
||||
printf ("%p %p\n", int_table.search (60), int_table.search (90));
|
||||
printf ("%d %d\n", int_table.remove (60), int_table.remove (60));
|
||||
printf ("%d %d\n", int_table.remove (70), int_table.remove (70));
|
||||
|
||||
/*
|
||||
printf ("%d\n", int_table[90]);
|
||||
printf ("%d\n", int_table[9990]);
|
||||
*/
|
||||
|
||||
//Str1Table s1 (NULL, 1000);
|
||||
Str1Table s1 (NULL, 0);
|
||||
//Str1Table s1;
|
||||
s1.insert ("hello", 20);
|
||||
s1.insert ("hello", 20);
|
||||
s1.insert ("hello kara", 20);
|
||||
|
||||
s1.insert ("this is good", 3896);
|
||||
printf ("remove = %d\n", s1.remove ("hello"));
|
||||
printf ("remove = %d\n", s1.remove ("hello"));
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
char buf[128];
|
||||
sprintf (buf, "surukaaaa %d", i);
|
||||
s1.insert (buf, i * 2);
|
||||
}
|
||||
|
||||
printf ("%d\n", (int)s1.getSize());
|
||||
for (Str1Table::Iterator it = s1.getIterator(); it.isLegit(); it++)
|
||||
{
|
||||
Str1Table::Pair& pair = *it;
|
||||
printf ("[%s] [%d]\n", pair.key.c_str(), pair.value);
|
||||
}
|
||||
|
||||
|
||||
printf ("------------------\n");
|
||||
{
|
||||
Str1Table s11 (s1);
|
||||
for (Str1Table::Iterator it = s11.getIterator(); it.isLegit(); it++)
|
||||
{
|
||||
Str1Table::Pair& pair = *it;
|
||||
printf ("[%s] [%d]\n", pair.key.c_str(), pair.value);
|
||||
}
|
||||
}
|
||||
|
||||
printf ("------------------\n");
|
||||
{
|
||||
Str1Table s11 (&heap_mmgr, 0);
|
||||
//Str1Table s11 (NULL, 200);
|
||||
//Str1Table s11;
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
char buf[128];
|
||||
sprintf (buf, "abiyo %d", i);
|
||||
s11.insert (buf, i * 2);
|
||||
}
|
||||
printf ("%d\n", s11.heteroremove<const char*, cstr_comparator> ("abiyo 12"));
|
||||
printf ("%d\n", s11.heteroremove<const char*, cstr_comparator> ("abiyo 12"));
|
||||
printf ("SIZE => %d\n", (int)s11.getSize());
|
||||
for (Str1Table::Iterator it = s11.getIterator(); it.isLegit(); it++)
|
||||
{
|
||||
Str1Table::Pair& pair = *it;
|
||||
printf ("[%s] [%d]\n", pair.key.c_str(), pair.value);
|
||||
}
|
||||
printf ("------------------\n");
|
||||
|
||||
//s11.clear (true);
|
||||
|
||||
s11 = s1;
|
||||
printf ("SIZE => %d\n", (int)s11.getSize());
|
||||
for (Str1Table::Iterator it = s11.getIterator(); it.isLegit(); it++)
|
||||
{
|
||||
Str1Table::Pair& pair = *it;
|
||||
printf ("[%s] [%d]\n", pair.key.c_str(), pair.value);
|
||||
}
|
||||
|
||||
|
||||
printf ("-------------------\n");
|
||||
Str1Table::Pair* pair = s11.heterosearch<const char*, cstr_comparator> ("surukaaaa 13");
|
||||
if (pair) printf ("%d\n", pair->value);
|
||||
else printf ("not found\n");
|
||||
|
||||
s11.update ("surukaaaa 13", 999);
|
||||
s11.update ("surukaaaa 16", 99999);
|
||||
s11.inject ("surukaaaa 18", 999999, 1);
|
||||
|
||||
pair = s11.heterosearch<const char*, cstr_comparator> ("surukaaaa 13");
|
||||
if (pair) printf ("%d\n", pair->value);
|
||||
else printf ("not found\n");
|
||||
|
||||
|
||||
s1 = s11;
|
||||
}
|
||||
|
||||
printf ("-------------------\n");
|
||||
printf ("%d\n", (int)s1.getSize());
|
||||
for (Str1Table::ConstIterator it = s1.getConstIterator(); it.isLegit(); it++)
|
||||
{
|
||||
const Str1Table::Pair& pair = *it;
|
||||
printf ("[%s] [%d]\n", pair.key.c_str(), pair.value);
|
||||
}
|
||||
|
||||
printf ("-------------------\n");
|
||||
|
||||
#if 0
|
||||
for (Str1Table::PairNode* np = s1.getTailNode(); np; np = np->getPrevNode())
|
||||
{
|
||||
Str1Table::Pair& pair = np->value;
|
||||
printf ("[%s] [%d]\n", pair.key.c_str(), pair.value);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/path.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
#if defined(_WIN32)
|
||||
@ -33,7 +33,7 @@ static int rex_main (int argc, qse_char_t* argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
qse_rex_setoption (rex, QSE_REX_STRICT);
|
||||
qse_rex_setopt (rex, QSE_REX_STRICT);
|
||||
|
||||
start = qse_rex_comp (rex, argv[1], qse_strlen(argv[1]));
|
||||
if (start == QSE_NULL)
|
||||
@ -70,9 +70,10 @@ static int rex_main (int argc, qse_char_t* argv[])
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
int x;
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
@ -80,15 +81,18 @@ int qse_main (int argc, qse_achar_t* argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
return qse_runmain (argc, argv, rex_main);
|
||||
qse_openstdsios ();
|
||||
x = qse_runmain (argc, argv, rex_main);
|
||||
qse_closestdsios ();
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/sll.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
|
||||
#define R(f) \
|
||||
@ -60,6 +60,8 @@ static int test1 ()
|
||||
|
||||
int main ()
|
||||
{
|
||||
qse_openstdsios ();
|
||||
R (test1);
|
||||
qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
#include <wchar.h>
|
||||
@ -194,9 +194,11 @@ static int test3 (void)
|
||||
|
||||
int main ()
|
||||
{
|
||||
int x;
|
||||
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
@ -204,8 +206,8 @@ int main ()
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
|
||||
@ -218,13 +220,15 @@ int main ()
|
||||
#endif
|
||||
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
|
||||
qse_openstdsios ();
|
||||
R (test1);
|
||||
R (test2);
|
||||
R (test3);
|
||||
qse_closestdsios ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
54
qse/samples/cmn/sp01.cpp
Normal file
54
qse/samples/cmn/sp01.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#include <stdio.h>
|
||||
#include <qse/cmn/ScopedPtr.hpp>
|
||||
#include <qse/cmn/HeapMmgr.hpp>
|
||||
|
||||
|
||||
class X
|
||||
{
|
||||
public:
|
||||
X()
|
||||
{
|
||||
printf ("X constructured\n");
|
||||
}
|
||||
|
||||
~X()
|
||||
{
|
||||
printf ("X destructed\n");
|
||||
}
|
||||
};
|
||||
|
||||
struct destroy_x_in_mmgr
|
||||
{
|
||||
void operator() (X* x, void* arg)
|
||||
{
|
||||
x->~X();
|
||||
::operator delete (x, (QSE::Mmgr*)arg);
|
||||
}
|
||||
};
|
||||
|
||||
int main ()
|
||||
{
|
||||
QSE::HeapMmgr heap_mmgr (QSE::Mmgr::getDFL(), 30000);
|
||||
|
||||
{
|
||||
QSE::ScopedPtr<X> x1 (new X);
|
||||
}
|
||||
printf ("----------------------------\n");
|
||||
|
||||
{
|
||||
QSE::ScopedPtr<X,QSE::ScopedPtrArrayDeleter<X> > x3 (new X[10]);
|
||||
}
|
||||
printf ("----------------------------\n");
|
||||
|
||||
{
|
||||
//QSE::ScopedPtr<X> x2 (new(&heap_mmgr) X, destroy_x);
|
||||
QSE::ScopedPtr<X,destroy_x_in_mmgr> x2 (new(&heap_mmgr) X, &heap_mmgr);
|
||||
}
|
||||
printf ("----------------------------\n");
|
||||
{
|
||||
QSE::ScopedPtr<X,QSE::ScopedPtrMmgrDeleter<X> > x4 (new(&heap_mmgr) X, &heap_mmgr);
|
||||
}
|
||||
printf ("----------------------------\n");
|
||||
|
||||
return 0;
|
||||
}
|
69
qse/samples/cmn/sp02.cpp
Normal file
69
qse/samples/cmn/sp02.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include <stdio.h>
|
||||
#include <qse/cmn/SharedPtr.hpp>
|
||||
#include <qse/cmn/HeapMmgr.hpp>
|
||||
|
||||
class X
|
||||
{
|
||||
public:
|
||||
X(int y = 0): y(y)
|
||||
{
|
||||
printf ("X(%d) constructured\n", this->y);
|
||||
}
|
||||
|
||||
~X()
|
||||
{
|
||||
printf ("X(%d) destructed\n", this->y);
|
||||
}
|
||||
|
||||
int y;
|
||||
};
|
||||
|
||||
struct destroy_x_in_mmgr
|
||||
{
|
||||
void operator() (X* x, void* arg)
|
||||
{
|
||||
x->~X();
|
||||
::operator delete (x, (QSE::Mmgr*)arg);
|
||||
}
|
||||
};
|
||||
|
||||
void f2 ()
|
||||
{
|
||||
QSE::HeapMmgr heap_mmgr (QSE::Mmgr::getDFL(), 30000);
|
||||
QSE::HeapMmgr heap_mmgr_2 (QSE::Mmgr::getDFL(), 30000);
|
||||
QSE::SharedPtr<X> y (new X(1));
|
||||
QSE::SharedPtr<X,QSE::SharedPtrMmgrDeleter<X> > k (&heap_mmgr);
|
||||
|
||||
{
|
||||
QSE::SharedPtr<X> x1 (y);
|
||||
}
|
||||
printf ("----------------------------\n");
|
||||
|
||||
{
|
||||
QSE::SharedPtr<X,QSE::SharedPtrArrayDeleter<X> > x3 (new X[10]);
|
||||
}
|
||||
printf ("----------------------------\n");
|
||||
|
||||
{
|
||||
//QSE::SharedPtr<X> x2 (new(&heap_mmgr) X, destroy_x);
|
||||
QSE::SharedPtr<X,destroy_x_in_mmgr> x2 (&heap_mmgr, new(&heap_mmgr) X(2), &heap_mmgr);
|
||||
}
|
||||
printf ("----------------------------\n");
|
||||
|
||||
{
|
||||
QSE::SharedPtr<X,QSE::SharedPtrMmgrDeleter<X> > x4 (new(&heap_mmgr_2) X(3), &heap_mmgr_2);
|
||||
|
||||
k = x4;
|
||||
QSE::SharedPtr<X,QSE::SharedPtrMmgrDeleter<X> > x5 (k);
|
||||
}
|
||||
printf ("----------------------------\n");
|
||||
|
||||
QSE_ASSERT (k->y == 3);
|
||||
}
|
||||
|
||||
|
||||
int main ()
|
||||
{
|
||||
f2 ();
|
||||
return 0;
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
@ -384,6 +383,7 @@ int main ()
|
||||
setlocale (LC_ALL, "");
|
||||
#endif
|
||||
|
||||
qse_openstdsios ();
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
qse_printf (QSE_T("Set the environment LANG to a Unicode locale such as UTF-8 if you see the illegal XXXXX errors. If you see such errors in Unicode locales, this program might be buggy. It is normal to see such messages in non-Unicode locales as it uses Unicode data\n"));
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
@ -401,6 +401,8 @@ int main ()
|
||||
R (test16);
|
||||
R (test17);
|
||||
|
||||
qse_closestdsios ();
|
||||
|
||||
#if defined(_WIN32)
|
||||
SetConsoleOutputCP (old_cp);
|
||||
#endif
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
#if defined(_WIN32)
|
||||
@ -81,9 +81,11 @@ static int test_main (int argc, qse_char_t* argv[])
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
int x;
|
||||
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
@ -91,14 +93,19 @@ int qse_main (int argc, qse_achar_t* argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
return qse_runmain (argc, argv, test_main);
|
||||
|
||||
qse_openstdsios ();
|
||||
x = qse_runmain (argc, argv, test_main);
|
||||
qse_closestdsios ();
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
#include <qse/cmn/time.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
@ -175,11 +175,13 @@ int main ()
|
||||
{
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
qse_openstdsios ();
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
qse_printf (QSE_T("Set the environment LANG to a Unicode locale such as UTF-8 if you see the illegal XXXXX errors. If you see such errors in Unicode locales, this program might be buggy. It is normal to see such messages in non-Unicode locales as it uses Unicode data\n"));
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
|
||||
R (test1);
|
||||
qse_closestdsios ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <qse/cmn/path.h>
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
#if defined(_WIN32)
|
||||
@ -77,9 +77,10 @@ oops:
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
int x;
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
@ -87,14 +88,17 @@ int qse_main (int argc, qse_achar_t* argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
return qse_runmain (argc, argv, test_main);
|
||||
qse_openstdsios ();
|
||||
x = qse_runmain (argc, argv, test_main);
|
||||
qse_closestdsios ();
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <qse/cmn/uri.h>
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#include <locale.h>
|
||||
#if defined(_WIN32)
|
||||
@ -116,9 +116,10 @@ static int test_main (int argc, qse_char_t* argv[])
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
int x;
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
@ -126,14 +127,17 @@ int qse_main (int argc, qse_achar_t* argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
return qse_runmain (argc, argv, test_main);
|
||||
qse_openstdsios ();
|
||||
x = qse_runmain (argc, argv, test_main);
|
||||
qse_closestdsios ();
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <qse/cmn/xma.h>
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
|
||||
#define R(f) \
|
||||
do { \
|
||||
@ -146,14 +146,30 @@ static int test4 ()
|
||||
qse_xma_close (xma);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void* xma_alloc (qse_mmgr_t* mmgr, qse_size_t size)
|
||||
{
|
||||
return qse_xma_alloc (mmgr->ctx, size);
|
||||
}
|
||||
|
||||
static void* xma_realloc (qse_mmgr_t* mmgr, void* ptr, qse_size_t size)
|
||||
{
|
||||
return qse_xma_realloc (mmgr->ctx, ptr, size);
|
||||
}
|
||||
|
||||
static void xma_free (qse_mmgr_t* mmgr, void* ptr)
|
||||
{
|
||||
qse_xma_free (mmgr->ctx, ptr);
|
||||
}
|
||||
|
||||
static int test5 ()
|
||||
{
|
||||
void* ptr[100];
|
||||
qse_mmgr_t xmammgr =
|
||||
{
|
||||
(qse_mmgr_alloc_t)qse_xma_alloc,
|
||||
(qse_mmgr_realloc_t)qse_xma_realloc,
|
||||
(qse_mmgr_free_t)qse_xma_free,
|
||||
xma_alloc,
|
||||
xma_realloc,
|
||||
xma_free,
|
||||
QSE_NULL
|
||||
};
|
||||
|
||||
@ -202,10 +218,12 @@ static int test5 ()
|
||||
|
||||
int main ()
|
||||
{
|
||||
qse_openstdsios ();
|
||||
R (test1);
|
||||
R (test2);
|
||||
R (test3);
|
||||
R (test4);
|
||||
R (test5);
|
||||
qse_closestdsios ();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user