diff --git a/ods/.gitignore b/ods/.gitignore new file mode 100644 index 0000000..c61ba60 --- /dev/null +++ b/ods/.gitignore @@ -0,0 +1,26 @@ +# data files +data/corpus.txt +data/cpp +data/ods-cpp.tgz + +# autotools junk files +.deps +Makefile +Makefile.in +aclocal.m4 +autom4te.cache/ +compile +config.* +configure +depcomp +install-sh +libtool +ltmain.sh +m4/ +missing + +# build artifacts +src/*.o +src/ch??ex?? +src/*.la +src/*_bench diff --git a/ods/Dockerfile b/ods/Dockerfile new file mode 100644 index 0000000..6dc025c --- /dev/null +++ b/ods/Dockerfile @@ -0,0 +1,25 @@ +# C++ build environment. Useful with the following script that should +# be run from a repo: +##!/bin/sh +# +#CONTAINER="{CONTAINER:-cc-build:latest}" +# +#docker run -i -t -v $(pwd):/workspace ${CONTAINER} bash +# +# NB: Ubuntu 17.10 seems to be the only common distro with C++17 support. +FROM ubuntu:17.10 +MAINTAINER kyle + +# install tools +RUN apt-get -y update && apt-get -y install clang-5.0 autoconf automake libtool cmake ninja-build texinfo curl mg + +# make the env pick up the correct compilers. +ENV CXX=clang++-5.0 +ENV CC=clang-5.0 + +# set up workspace +RUN mkdir /workspace +WORKDIR /workspace + +# start compiling already +CMD "bash" diff --git a/ods/Makefile.am b/ods/Makefile.am new file mode 100644 index 0000000..bc31d7e --- /dev/null +++ b/ods/Makefile.am @@ -0,0 +1,5 @@ +ACLOCAL_AMFLAGS = -I m4 +SUBDIRS = src data + +benchmarks: + cd src && make benchmarks \ No newline at end of file diff --git a/ods/README.md b/ods/README.md new file mode 100644 index 0000000..ffd05b2 --- /dev/null +++ b/ods/README.md @@ -0,0 +1,16 @@ +# ODS +## Open Data Structures + +This is an implementation and playground for the code in the +[Open Data Structures](http://opendatastructures.org/) books. +It contains both the C++ and Python repos. + +Tree: + +``` +. +├── include # C++ headers +├── notes # notes from the text +├── ods # Python sources +└── src # C++ sources +``` diff --git a/ods/autobuild b/ods/autobuild new file mode 100644 index 0000000..d82c3d3 --- /dev/null +++ b/ods/autobuild @@ -0,0 +1,31 @@ +#!/bin/sh +set -eux + +command -v clang 2>&1 > /dev/null && CXX=clang++ +CXX=${CXX:-g++} +CONFOPTS="CXX=$CXX" + +SILENT="${SILENT:-yes}" +if [ "${SILENT}" = "yes" ] +then + CONFOPTS="$CONFOPTS" +fi + +[ -d m4 ] || mkdir m4 + +if [ "$(uname -o)" = "Android" ] +then + SRCDIR="$(pwd)" + BUILDDIR=$HOME/build/ods + [ -d "$BUILDDIR" ] && rm -rf $BUILDDIR + mkdir -p $BUILDDIR && cd $BUILDDIR + autoreconf -i $SRCDIR + bash $SRCDIR/configure $CONFOPTS + [ -d "$BUILDDIR/data" ] || mkdir "$BUILDDIR/data" + cp $SRCDIR/data/corpus* "$BUILDDIR/data" +else + autoreconf -i + ./configure $CONFOPTS +fi +pwd +make diff --git a/ods/benchmarks.txt b/ods/benchmarks.txt new file mode 100644 index 0000000..5a4b5b9 --- /dev/null +++ b/ods/benchmarks.txt @@ -0,0 +1,13 @@ +cd src && make benchmarks +make[1]: Entering directory '/home/build/ods/src' +LIST BENCHMARKS +SimpList @ 1000000 ops: 1.96438s +VList @ 1000000 ops: 1.91541s +LinkedList @ 1000000 ops: 4.02349s + +USET BENCHMARKS +SimpUSet @ 1000000 ops: 1.19608s + +SSET BENCHMARKS +SimpSSet @ 1000000 ops: 1.29316s +make[1]: Leaving directory '/home/build/ods/src' diff --git a/ods/caret-project.json b/ods/caret-project.json new file mode 100644 index 0000000..324d1f8 --- /dev/null +++ b/ods/caret-project.json @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "retained": "5E0521C79B127562CFF1091E1D9E33B1:ods", + "path": "/ods" + } + ] +} \ No newline at end of file diff --git a/ods/configure.ac b/ods/configure.ac new file mode 100644 index 0000000..866c5d3 --- /dev/null +++ b/ods/configure.ac @@ -0,0 +1,25 @@ +# autoconf version 2.68 and automake version 1.11 seem to be the latest +# versions that can be used with Travis right now. +AC_PREREQ([2.68]) +AC_INIT([ods], + [0.1.0], + [coder@kyleisom.net], + [ods], + [https://github.com/kisom/ods/]) +AM_INIT_AUTOMAKE([1.11 foreign]) + +AC_CONFIG_SRCDIR([src/ch01ex01.cc]) +AC_CONFIG_FILES([Makefile src/Makefile data/Makefile]) +AC_CONFIG_MACRO_DIR([m4]) + +: ${CXXFLAGS=""} + +PKG_PROG_PKG_CONFIG +AC_CHECK_HEADERS + +LT_INIT +AC_PROG_CXX +AC_PROG_INSTALL +AC_PROG_CC_C_O + +AC_OUTPUT diff --git a/ods/cxe b/ods/cxe new file mode 100755 index 0000000..cf1203d --- /dev/null +++ b/ods/cxe @@ -0,0 +1,5 @@ +#!/bin/sh + +CONTAINER="{CONTAINER:-cc-build:latest}" + +docker run -i -t -v $(pwd):/workspace ${CONTAINER} bash diff --git a/ods/data/Makefile.am b/ods/data/Makefile.am new file mode 100644 index 0000000..dbd6f14 --- /dev/null +++ b/ods/data/Makefile.am @@ -0,0 +1,12 @@ +pkgdata_DATA = corpus.txt ods-cpp/main.cpp + +corpus.txt: corpus.txt.gz + gzip -d -k $@.gz + +ods-cpp/main.cpp: ods-cpp.tgz + tar xzf ods-cpp.tgz + +ODS_SAMPLE_CODE_URL := http://opendatastructures.org/ods-cpp.tgz +ods-cpp.tgz: + if command -v curl 2>&1 > /dev/null ; then curl -L -O $(ODS_SAMPLE_CODE_URL) ; \ + elif command -v curl 2>&1 > /dev/null ; then wget $(ODS_SAMPLE_CODE_URL) ; fi diff --git a/ods/data/corpus-micro.txt b/ods/data/corpus-micro.txt new file mode 100644 index 0000000..de084c2 --- /dev/null +++ b/ods/data/corpus-micro.txt @@ -0,0 +1,18 @@ +' I am a black clouds away, and Victoria Hotel. +' I am in changed; and all that he no one can and the cocks were taking part of the flèches were silent. +' I even the time. +' I am not know about forty. +' I am to make the men of the staff officer, youthful Speránski smiled scornfully. +' I am waiting he reached Málo Yaroslávets, after her, was becoming it is it from his pace. +' I am in changed; and all that he no one can and the cocks were taking part of the flèches were silent. +' I am! Mr Dedalus rose and troubled, my best so lately, and its whole campaign, involuntarily she thought of an entreaty and he had occurred; in memory. +' I beg first to see you can explain his head cook and began speaking to come up to look. +' I can tell you know how he spoke the commencement of bare round at once handsome young man Peter Kirílovich, trying to early mass droned and in his horse, a general interest of God s room. +' I cannot. +' I considered it s I? Is it comes back of vexation. +' I did not against an apprehensive glance. +' I did not hanging down. +' I considered it s I? Is it comes back of vexation. +' I did so. +' I didn t sleep, Mamma. +' I even the time. diff --git a/ods/data/corpus-small.txt b/ods/data/corpus-small.txt new file mode 100644 index 0000000..c8fa906 --- /dev/null +++ b/ods/data/corpus-small.txt @@ -0,0 +1,251 @@ +' I am a black clouds away, and Victoria Hotel. +' I am in changed; and all that he no one can and the cocks were taking part of the flèches were silent. +' I am not know about forty. +' I am to make the men of the staff officer, youthful Speránski smiled scornfully. +' I am waiting he reached Málo Yaroslávets, after her, was becoming it is it from his pace. +' I am! Mr Dedalus rose and troubled, my best so lately, and its whole campaign, involuntarily she thought of an entreaty and he had occurred; in memory. +' I beg first to see you can explain his head cook and began speaking to come up to look. +' I can tell you know how he spoke the commencement of bare round at once handsome young man Peter Kirílovich, trying to early mass droned and in his horse, a general interest of God s room. +' I cannot. +' I considered it s I? Is it comes back of vexation. +' I did not against an apprehensive glance. +' I did not hanging down. +' I did so. +' I didn t sleep, Mamma. +' I even the time. +' I explain to lead, when in a step nobody and the French fell as soon as being used to do, and position among these two barrels of men from the yelp, thought that the Slobóda Palace to sit at the feather bed during the first declared the middle of your own or the French, Stephen, wearing a countinghouse clerk, having made him and how he has been put his soul of his coat. +' I have to reduce utterly impossible to him from him pleasure in fact that stood on Pierre. +' I ll pass. +' I m an angel, and very rich satin cloak? So said. +' I mean, dissipated life our hands irritated her whole evening he rejoiced as soon have ended, make out of fearful joy in all sides by hounds had taken place has recovered her, kept asking whether he said Dear, Zherkóv. +' I nearly seventy miles out the most intimate friends, said Prince Andrew in the committee. +' I ran away. +' I shall scarcely interpret the soldiers, my feet with dissatisfaction and the force, his opponent with widely!. +' I shan t have received, dark air of maintaining that she cried, and of a pretty old playmate? she was passing loudly and was expected him here, and that the fear before, wearing a placard. +' I should have others on with his hair at when he threatened by alienating me, and this was the following a French had more tea, Nicholas? Please, it. +' I should look of all, both hands and we shall I know or auburn no longer wanted to the voices together that the hounds. +' I so he! the way with a wild and papers please the musicians blundered looks, was the evening I wrote French soldiers who wanted. +' I spent the class he will plow the porch. +' I suppose you are on it had been saying The old prince used to change your doing no freedom. +' I taken place was not marry n. +' I tell him in a trunk on the children were themselves from me! exclaimed several times and therefore bound him on the country that he was going up in bed. +' I tell him to God grant that for the second and was fond of the French troops there. +' I think it for the right, if by the dean. +' I think? Why are you please don t detain, and from him and again, said to Sventsyáni we were extra current rumors were talking to all. +' I thought. +' I to the carriage, but themselves as he said Alpátych, she tried to retreat, he felt himself killed wounded men will also because Kutúzov rode up. +' I want me to the click at the dinner tomorrow. +' I was exposed in her when Balashëv bowed to him and truth which showed itself least fatigue, seeing a man who felt that afternoon. +' I was still hearing their own accord and working at once, a man and touched the others were fixed on the whole Russian bath and unexpected and his young men who questioned him, or displayed during supper he did now? exclaimed different. +' I were approaching with a part in Kiev? Yes, will do today. +' I wish it, verse as her face, but all this speech. +' I would make me, even there was sincerely agreed or firmly. +' I. +' I? Stephen said that she really true hussar. +' In an excellent man as if I don t time quite Russian army. +' In marrying me to the room at the end of the tortoise he wrote giving them, but it in the village Elder? asked where she even if you, and over, world chaste blessings be appointed position opposite hill amid the letter has so much confused when my face and holding the sitting some strange on some latent patriotism which Pierre rubbed or feeding from him now? She felt a general had procured himself began speaking of October when Princess Mary raised, must be at what was ready to manhood, thank you, they belonged the war is own peculiarities and out on a shape arises a tall figure in and looked at the mighty eagle's beak a splendid provinces as often happens! cried, sits down, proved to give his customary carelessness as if they alone stood in a boy, come only very glad, I could that his wish it to the rocks and men could hear the adve sawies have so simple and Baron Stein were trying to him. +' In passing out of the train'd soprano, others will not tear stained wood and pass the words what had not stir it seemed to Pierre now let us again as meant that society, seemed undeservedly cold and with surprise to do you call to him from the apparently original army. +' While upon it is another day had thought of Moscow, The gossip to kiss him. +' o my dear man is perfectly first benches in a divan, Natásha was the sleepless night dews, coming of Olmütz to plant in lowly Lamb of personality. +'s Purport Not only two candles, the will in Petersburg, and even full sail countless crowds of maple woods, as other! Unscrew the freighted to confirm that it? Yes, looking at once for himself as she knew she must think? He was about her face she understood that old people at the face, o to go on the forces. +1 2 3. +1 2 Ah. +1 2 For that consciousness of Moscow friends. +1 2 His face, walked twice Pierre closed over the kind, who, repeating a fellow countrymen are not at him? said Lynch. +1 2 I began thinking she felt a man, embracing his first place at his hand. +1 2 It s requirements. +1 2 It was told him or at headquarters was sitting of the scope of the wife and quite irrelevant and went. +1 2 Only, la pluie et quasi myrrha electa dedi suavitatem odoris. +1 2 Such supplies were clearing, thought to ze Emperor s at inns, collapsed into everlasting sky, said Countess Zúbova, some hot tea, smiling at his horse back and of yesterday and happily to Plutarch speaks of our men assumes the wall and velvet chair with the scene and took them. +1 2 That s rapturous smile and young man had noticed the actions we apprehend it s seemed. +1 2 The soldiers were tears for the doctor, little old prince began taking part in the time shall be daylight soon as if to the count, or understand. +1 2 the work. +1 2. +1 Afoot and a great. +1 Ah! he told me good deal with his head in the captain who saved. +1 Ah! said to the slopes. +1 Ah, By refuting this stinking mean good humored laughter from the soldiers ran up and for me. +1 Ah, effulgently flowing hair. +1 Ah, when you not correspond to consider the stupidity, And Dólokhov kept looking at Krásnoe, though she added in a lot of thousands they have perused it came up and pour in step, with the apparently the same there where he did not recall her. +1 Ah. +1 An Army Orders of the countess, with a power. +1 An officer had to the gushing showers have done with that love. +1 An officer. +1 An old boy trots on seeing her present life. +1 As the tongue, the men rose to be any plan of the staff had seen Grékov with their conversation, vane, smiled. +1 Chanting the age ratified all torn my soldiers be enrolled new musing late stood, tell you, and fasts of fever assumed more rapidly established her presence. +1 For, And me your theology in comparison with me? The satisfaction which and Alexander and as pure mathematics, or left against the Cossack regiments have seen through the infants, I d been placed a little shrieks of a pair of friend, alternately or whether or distributing this to get ahead. +1 From Baldhead, all the Guards, in and delicate, your honor, at the regiment, helped him and cheeks, he had so much caution and the twentieth of guts up and fifty, for pardon for great eyes were not why. +1 From Sventsyáni they contain a cannon ball, a step towards the Queen of August I tell you. +1 From all he tried to do good as a strained to His fertile mind, but skipped down; and what was dead friend, and the streets. +1 From all, do not the devils! Commander of the good deal with an armchair. +1 From all, the path. +1 From behind it. +1 From morning. +1 From the Sparrow Hills it. +1 From the charming woman became silent till all grew flurried on both hands, nonrecognition of occupation. +1 From the creditors threatened to look established in the battery and women Pierre inquired Prince Andrew! Bagratión turned to the damned in the count. +1 From the next day he spoke distinctly, only the Russian commanders of that I thinking of the water for him. +1 From the party entanglements can sometimes keeping him to business with Sónya, getting up a time Natásha. +1 From the thought, and evidently impossible. +1 From the warmest advocates of his marshals and insisted on the first step. +1 From today at the college of fear resembling those near the pale face reminded her. +1 From where the first case, my calèche. +1 Give it! he very often occupied her in toys for them by, there was just possible, America, As often begun such innocent games? That was only after the army is therefore before a good deal with their party there was saying Our fugitives returned to say. +1 Give me enchain'd a baby. +1 Hark, excited faces, and the wooded ravines, the formative chaos, but what? asked. +1 However far. +1 However inaccessible, Nicholas, long story of entering on the French officers, resting troops below the wag. +1 However much stronger flow of the big dishes, o lord, of a sovereign the officers began to be the quartermaster, he used to Moscow and accept for two richest. +1 However much to reign of supreme judge by its anxious and fumbled for her might. +1 However often over the old soldier who saw that would not caused by an excellent dispositions which he had been sent with his tea, I will be as he is my fault but not yet shy, with here s Cossacks were quite well known as she would no small gray horses have what she had been a long time she well, and what was being sent to us all that his, for ever to restrain herself. +1 However painful death of joy. +1 However, Natásha was the complex laws of soldiers near the voices came from his son from Smolénsk as bewitching smiles generally the door Dante, who heard nothing. +1 However, and of the blackish cheeks, said to awake. +1 However, as it seems to right and be shown to the parted behind this kind sprang from him and set down the doctor noticed how this down the special force producing effects with them for Kurágin made life, I, Papa must forget him to her when he rose slowly out my consent. +1 However, attack by another than all a general conversation with his honor. +1 However, lighting up and according to me to her. +1 However, nor heard anything, that moment, I do you want to his collar. +1 However, should expect this and that you want with a swarm of the Great Square, and when he saw the names on the old man was so often wondered how they did you see what! He saw by anything, Stephen tried to Thee, Anatole to punish the sun or by an opportunity to be secret society, Napoleon and continuing to serve in his body. +1 However, till then, aglow; an historic events remain only wear their simple reflection. +1 However, to Ramballe, but without a good a storm of their passions, examining something terrible and yet your taste and he exclaimed Natásha up to speak. +1 I agree to notice of it won t you take me most necessary to the room sofa in from the bows, she had seen in the majority of the visitors to a drunken men who usually pitiless enough for a waltz. +1 I am afraid when he was a way and your Honor. +1 I am only on his pocket. +1 I crept about the carol mornings, and branches, staffs, made nowadays are cut and behind them a good, drew nearer. +1 I desire for not suppose it might brush against him that he should not for their terror seized the way back. +1 I explain frankly I love her shriveled head a devout, that of it, is exhausted by putrefaction of losing sight of his thoughts that. +1 I ll die in his right. +1 I looked at once for tea, out her face and the officers were veiled by the orchard, was plain between ourselves as the burial cairns of two hundred rubles a diary? Eh, lying in the wide right to despair and genius of dung. +1 I looked up. +1 I m heartily sorry to Sónya. +1 I must not agree with love love still to commerce, which Pierre s to the rice, what it nor a dinner Anna Pávlovna, man when the prince appeared to the Duke of gray haze. +1 I please. +1 I saw that seemed to get away? asked. +1 I was going with the rapt with a defect was kissing her letters, All Seas of talking, Dear Natalie, turned to express their coiffures and sentiments of the dust and duly flame in the dam, thought of generation, sat erect till the line. +1 I will fly off where men of his head was she was dancing, walking through which made it may the Boulogne, the pond side with naïve terror that, and said the shining, said. +1 I, and fire, was in a second broadsheet. +1 Kutúzov and began quickly, as far away at Boguchárovo shortly. +1 Kutúzov at your icon of war, condemned to the Order of their journey of the dissemination of execration; so on either. +1 Kutúzov checked from Tíkhon, shouted. +1 Kutúzov despised them Pierre remembered Denísov had had ordained by his most likely be taken up. +1 Kutúzov did Prince Andrew came the absence of advisers served as they split logs were to their words. +1 Kutúzov did kindle fires from him, trembling and respected members of the news which he had been announced the other singers, had thought as though I hope and sleep, lost and closed the midst of your possession of the trial cannot be so when he understood that sin had on its sober and stood a pleasure. +1 Kutúzov did not leave, and pencil and voices that those personal reminiscences, and even made no covering his mouth. +1 Kutúzov evidently had been fought?. +1 Kutúzov had at work so it was a vague sort of something to Moscow. +1 Kutúzov s wife s household. +1 Kutúzov signed the house. +1 Kutúzov was displeased that she heard them both had been used appositely suddenly felt it lifted his quarters, many drops from his little Nicholas telling you that regarding as he first stared straight on the scared expression to horses over the bad temper, and Arakchéev from the Knights of Prince Andrew, in his son who d have looked round happy plans submitted to hear the Pénza and standing still unbuttressed walls, my saber, on such vividness. +1 Kutúzov. +1 Man's Pants. +1 Man's Thought Of the princess. +1 Now don t recognize a good by Ramballe despised, trying for his arms rose and Paul Ivánovich, a day to his uniform of the crumbled mole on the glory that sometimes thought. +1 Now you paralyze it did not even danced if they took the germs of cinders had white ivory handle of things I mean? Pierre and the last he never to contradict myself waiting for earthly prisons, some particular man urged him who held their carts and therefore, in the coiling twice that feels, as if to be able to wait for thee an order in which reminded them all around lanes, and Pétya pale, his way better we were reluctant to attach to questions about it had not dulled by day. +1 Now, gloomy and under your honor of the strange fields were weak men he kept a gigantic than the Chief Executive and forming endless confused poor corrupt data, reminded them in history have reason is listened to her dead, a part of the best unreck'd at the Tartar. +1 Of course of the neck distend, replied Bolkónski, and involuntarily thought and his name. +1 Of tears of by the army. +1 Out of incense before seen at the strong peaceful refuge of the body there. +1 Pair Buskins. +1 Power if those threads but Pierre made a walking beside his face, a moment the country for a couple of life he could not even have tried to answer that fights more, that the Russians. +1 Power indefinable bond that face gave the fellows, they should be so full strength at the brick stove. +1 Power is a funnel? And he went into Russia that the prisoner? When they descended the canvas and tell a red coat collar, Nicholas. +1 Power is away his geography a huge campfire listening to her eyes tried to you might have forgotten all the printing press them to assume the sea harvest, agree with the tent, successful and stress, miserable Godforsaken race among the frozen. +1 Power is called a hundred thousand rubles I lived in civilian clothes in the succeeding terms with him. +1 Power is dreadful plan for him as if he thought occurred; let us can t drink shop, said Nicholas, and going to pay arrived at the ambulance station on the command and Natásha had returned the docks and soldiers but that he let down the bridge that, too tightly buttoned up with shouts of this humble that nothing to discover a prisoner was drawn out was expected of which some of three hours on him to stab him go by himself to Stephen as often heard the beekeeper who is sentenced him? said the hem and stood with a lie down and rage Devil take a coward, who had hinted that the earth; but in charge of the enchanted days and seeing Anatole Kurágin. +1 Power is not long body of the young! In neither the larks rose to Rostóv almost fainting from sitting in 1820 and while they not reply to do that if startled by which seemed to charge anything for Natásha, as if when I pray there. +1 Power is vacillating, one, but Márya Dmítrievna and must live without cause as a few days of the adjutant. +1 Power, the plain. +1 Power. +1 Proud and that I know, mate and heaven is rejoicing in the candle burned his own feet that you have said Rostóv family fortune he could not call, and for the sounds which they denounce the one else. +1 Rang the braces that the casement. +1 Rang the freshness of death but he was very big stick. +1 Rise o wild horse and she paced up from laughing, touching you like a precursor of his soul had taken prisoner. +1 Sauntering the West, We women, splashing into the fate to do you ask for any difficulties, interlarding their shirts opening of manhood. +1 Sauntering the matter are to look on tiptoe and the true, and that morning light unwound from one!. +1 Self knowledge and downwards, old Smolénsk, trying not managed during his presence and not accept your return with her sobs with a year old prince to serve as a result of it known him. +1 Self knowledge of everything succeeds. +1 Self knowledge of larger forces. +1 Self knowledge of something special look for the Emperor when the ditch, hear election as before him, dear fellow, frequented. +1 Self knowledge of the matter to do and evil living verdure had there were hardly do it to her and took possession of the horse gallop and feel?. +1 Self knowledge were always shaggy old aunt without looking at him. +1 Self knowledge. +1 Self perfecting himself with his daughter, the genuine distress. +1 Self perfecting his spectacles seeing a swelling heart and hardly refrained from envy of affairs. +1 Self perfecting, and so particularly disturbed and out his eyes as indifferently at once began to be angry look at the two windows open doorway, I m certain types of the possibility of meeting her radiant face against the blood with you please! It was his sides came the portrait evidently concerned with the desks for Pfuel only arms. +1 Self perfecting, but as she was not at all the stronger and dishonored man wearing the ballroom with her and did you are conventional society of an order to him embraced softly and went into the suite were still stronger than it, replied that Prince Andrew s the whole household since the onlookers who sat down what he was not seem to all realize the old satyr. +1 Self perfecting, soldiers some horses, and in time for a borzoi who had finished his hands. +1 Self sacrifice herself would be kindly faces up with a ford, and I tell your name? a fine young man feels sure your excellency! Why is needed, Cossacks were so he would have been in step back to listen and silent and where the way out of 1813 Kutúzov when his feet long forgotten how she also what they say good master and lifting both sides black and stifles real meaning as quickly and bent double kits, upright. +1 Self sacrifice of human. +1 Self sacrifice, he felt that it, arrived to this, the envy of these men with the sting? replied to shield his own, sinfully. +1 Singing I should show you know that the same order to say. +1 Something unproved! she found in the cruel men, who die and whether they showed like that he come. +1 Starting I will not big strides from the cloak and ridicule of by his sister's care at the army! cried Vive l ha, brightening up and he raised and freedom there to convert to support to their beam, a large as if inviting him! Every foot of personal activity. +1 The Emperor, I go now at another instrument for Natásha, pushed on alone, a train. +1 The French availed today she had known him had probably was thereby proving to everything for wounded were still in those words mean, I know, bright kindly, said. +1 The French, almost impossible for the door opened, but rather guilty. +1 The Queen s have in pursuit, o God, I know pointing before him. +1 The army and seeing her, confess all very thing he told to continue. +1 The barrier the oak buds is a squad of youth who had gone? All in the captain. +1 The esaul looked at him grow fat like a letter up the line? thought Rostóv party of the one get on her imagination, contempt with beaming smile, then to Cranly, and the rest of his forefinger and hastened to call the study the soldiers who he had wished to the first went along the Minister meaning to carry to be mistaken, said Anatole entered more, with evident. +1 The faint rhythm, but he continued. +1 The fire, an event appeared on that the will all humanity and drenched, which were punished schoolboy trick me, listening to me, now agitated and determined concentrated in his chest expanded his father asked Pierre moved him. +1 The general with him as Pierre, his wife and how his round the others the same thing, Mamma! Then a moment of honor sees a word. +1 The house! And she had said Bagratión, authorities, abandoning their own view. +1 The interpreter addressed as a baby tuckoo. +1 The language? The blackish cheeks, said, his head over him, not get a triumphant cry. +1 The latter are not have a sleigh; you think. +1 The looks for much he had peacefully to her again. +1 The man with lovers once by the Russian commanders to speak and resignation, madam, just as they were heard, girt with whom thousands of it. +1 The offer which he had come his shining and grim look and arrogant blood and sure of Birth eternal. +1 The old, and for the reading because he began singing. +1 The order the correctness or evil but she had been there was around him her because Alexander refused to his lunch when this soldier of this consoling thought that something, and the count, that they could not take the enemy suddenly affected her. +1 The priest s plump hand. +1 The ribbon just effected the elderly laughter. +1 The terrified Ober Hofmarschal Count if independent of the evening he replied Nicholas into the chorus dances! repeated the French colonel! Yes, Papa is probably came and bony fingers while dying, with anything, he ought to Weyrother, outside time to see their point of generosity, when playing, and his senior officer named Aubrey carried away from side promised to the touchpans or that they had to utter a few days before, nor the sill to, and then? This flattered by frost was standing in a bottle! Which is the stripes on his own condemnation. +1 The unjust to theirs, whom she softly and excitedly that they are to the world, replied Princess Mary rose higher and swayed his skin, was a girl answered Dólokhov concluded, Princess Mary imagined how impossible to such thing into coronals of the further opportunities to dance, just as for, now, came round, the band, set apart, Pétya recognized that remained silent; these acquaintances, believed it, hand. +1 The vastness and glanced at the countess interrupted by all the nearness of the nursery, glancing at the more and with Bogdánich, and the whole affair. +1 The weather, where is, and in a man when troops crowded. +1 The whole world. +1 The young men who wished to her. +1 The young soldier, lads and were tears rising. +1 The youngest, biscuits, unreasoning hurry up her first entered the annals of the contrary to whistle loudly and was all sides. +1 To be better understood something from her brother with the air. +1 To escape, a similar feeling in consideration of the Tsar s why he heard of the cavalry saddles, charming. +1 To fluff out of cause, I have some reason for a wall. +1 To fuse, Pierre, dear knows how longingly I sing such a walk with a man in chief by the distribution must entice him with the majority who was not see men, what have duly with its former squadron, was right when you see a muffled voice, nor child mournest thou my egotism. +1 To get no obstacles may turn and tomorrow morning of the floor. +1 To search, returned to all bad, through the height of his seems as she listened, Prince Andrew, or suffering, for it occurred to Kutúzov gave her, munitions, the main army to hold out of Russia. +1 To that she was spread out, tomorrow we hope of the hands. +1 To the defense, frowning angrily to the action people, though only what it away. +1 To the present the bed, and the welfare of his name, that moment before yesterday not the sidle of wandering out, life in ourselves into an enormous puppy. +1 To the sound of the lean, taken their homes or himself before their box filled his head of doubt openly. +1 To this at times by Bagratión tried to console us down on his gorgeous feasts, but I want it could help me! Read locusts and pointed to Bagratión s will is the blanket, concluded with considerations tens of his mind his face and sounds of an impression of other branches of all the soldiers' slugs were Gervais, and with his fault, of divisions to his footgear having entertained by the Russian army ceased. +1 To your plate of other day, replied the children noiselessly in the carts, his chief continued the generals, even wish they would have one another way. +1 Weapon shapely strong upright lines and with this? I should go. +1 Weapon shapely strong?. +1 What a minimum of things going. +1 What am in Siberia and unknown quantity. +1 What are a supper. +1 What did not say with dozens of the doctor who is what I should not at Princess Mary tried to his helplessness. +1 What do believe me away and plainly. +1 What do but there by shaking her, the enemy. +1 What do that after the moment Nicholas inquired about new tenderness. +1 What does not like all these events may be repeating something by giving him to his breast and the same question of patience. +1 What gwace! Get along both generals. +1 What have a description of Prince Andrew, you a noncommissioned officer, we be talking of smoke rose with the bridge that the war not being made up, a kindly smile was betting with him, Balashëv made you up to the Armenians and enlightened by soldiers and property that kind friend, Pierre could not see, or not have been received, stretching out. +1 What if you how many forces, but not control of the company! exclaimed, blind! Against God. +1 What is any lady, refined sadness as well if a large group. +1 What is hesitating, looking at it was so much at her toilet which I am not answer such exactitude, in large house. +1 What is she had had moved through it lifted towards others fill, good to disagree with this is impossible to Thee enclosed for Rostóv s belief in their house realized the first preluding thee old men go without finishing his sufferings, And all crowded against the morning on his aides de Tolly, Nesvítski with snow. +1 What s time. + +1 What s words of France itself in peace, something strange as a rapier and Wednesday s life felt glad if they wish, which had on, the dogs; but as yet experienced than an unnatural smile of a combination of whom he had been able to which the Povarskóy, but this life wherein he himself subsequently did not help, was judged correctly that I have brought up on the enrollment, rode off his own place of Borodinó were little room without an elderly lady visitor performed just anyhow. +1 What struck at present state in Mademoiselle Bourienne thinks it reached it over it you to me, in his white neck. +1 What would have to say the transport to tell me! John Anthony's poor results which were more than they caught in a battle before and comprehended it seemed even this? said in my mouth to the overseer and retreat to demonstrate the unfolded his voice repeating. +1 What, but wanted to business of what is only possible to the freshness of his brows. +1 When explaining the signal shot into discontinuous elements, God has brought for war, arm of a door, the woman when he said Prince Andrew was pressed it and Baskirs, lighthearted! It suits me see the ivy, or wit Shinshín s visit him. +1 When he considered. +1 When he was in his cheek and resume the word with the princess arm, on his face was standing at the war another. +1 With the dancer stopped it possible? Bind him. +1 a strong bird, shaking and shaking his forehead as usual. diff --git a/ods/data/corpus.txt.gz b/ods/data/corpus.txt.gz new file mode 100644 index 0000000..28ac78e Binary files /dev/null and b/ods/data/corpus.txt.gz differ diff --git a/ods/debug.log b/ods/debug.log new file mode 100644 index 0000000..c609093 --- /dev/null +++ b/ods/debug.log @@ -0,0 +1,3177 @@ +==10897== Memcheck, a memory error detector +==10897== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. +==10897== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info +==10897== Command: src/list_bench +==10897== +--10897-- Valgrind options: +--10897-- -v +--10897-- Contents of /proc/version: +--10897-- Linux version 4.13.0-16-generic (buildd@lcy01-02) (gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu2)) #19-Ubuntu SMP Wed Oct 11 18:35:14 UTC 2017 +--10897-- +--10897-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-rdtscp-sse3-avx +--10897-- Page sizes: currently 4096, max supported 4096 +--10897-- Valgrind library directory: /usr/lib/valgrind +--10897-- Reading syms from /home/kyle/code/ods/src/list_bench +--10897-- Reading syms from /lib/x86_64-linux-gnu/ld-2.26.so +--10897-- Considering /lib/x86_64-linux-gnu/ld-2.26.so .. +--10897-- .. CRC mismatch (computed 8e133c77 wanted 4706bdfa) +--10897-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.26.so .. +--10897-- .. CRC is valid +--10897-- Reading syms from /usr/lib/valgrind/memcheck-amd64-linux +--10897-- Considering /usr/lib/valgrind/memcheck-amd64-linux .. +--10897-- .. CRC mismatch (computed 9fa343a0 wanted dc854ea8) +--10897-- object doesn't have a symbol table +--10897-- object doesn't have a dynamic symbol table +--10897-- Scheduler: using generic scheduler lock implementation. +--10897-- Reading suppressions file: /usr/lib/valgrind/default.supp +==10897== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-10897-by-kyle-on-??? +==10897== embedded gdbserver: writing to /tmp/vgdb-pipe-to-vgdb-from-10897-by-kyle-on-??? +==10897== embedded gdbserver: shared mem /tmp/vgdb-pipe-shared-mem-vgdb-10897-by-kyle-on-??? +==10897== +==10897== TO CONTROL THIS PROCESS USING vgdb (which you probably +==10897== don't want to do, unless you know exactly what you're doing, +==10897== or are doing some strange experiment): +==10897== /usr/lib/valgrind/../../bin/vgdb --pid=10897 ...command... +==10897== +==10897== TO DEBUG THIS PROCESS USING GDB: start GDB like this +==10897== /path/to/gdb src/list_bench +==10897== and then give GDB the following command +==10897== target remote | /usr/lib/valgrind/../../bin/vgdb --pid=10897 +==10897== --pid is optional if only one valgrind process is running +==10897== +--10897-- REDIR: 0x401f7b0 (ld-linux-x86-64.so.2:strlen) redirected to 0x58060901 (???) +--10897-- REDIR: 0x401f590 (ld-linux-x86-64.so.2:index) redirected to 0x5806091b (???) +--10897-- Reading syms from /usr/lib/valgrind/vgpreload_core-amd64-linux.so +--10897-- Considering /usr/lib/valgrind/vgpreload_core-amd64-linux.so .. +--10897-- .. CRC mismatch (computed f3fb86a7 wanted 0b99f9ab) +--10897-- object doesn't have a symbol table +--10897-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so +--10897-- Considering /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so .. +--10897-- .. CRC mismatch (computed 5ffa922b wanted 4228a583) +--10897-- object doesn't have a symbol table +==10897== WARNING: new redirection conflicts with existing -- ignoring it +--10897-- old: 0x0401f7b0 (strlen ) R-> (0000.0) 0x58060901 ??? +--10897-- new: 0x0401f7b0 (strlen ) R-> (2007.0) 0x04c32db0 strlen +--10897-- REDIR: 0x401d820 (ld-linux-x86-64.so.2:strcmp) redirected to 0x4c33ee0 (strcmp) +--10897-- REDIR: 0x401fcf0 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x4c374f0 (mempcpy) +--10897-- Reading syms from /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.24 +--10897-- object doesn't have a symbol table +--10897-- Reading syms from /lib/x86_64-linux-gnu/libm-2.26.so +--10897-- Considering /lib/x86_64-linux-gnu/libm-2.26.so .. +--10897-- .. CRC mismatch (computed 5c7a687c wanted e7414330) +--10897-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/libm-2.26.so .. +--10897-- .. CRC is valid +--10897-- Reading syms from /lib/x86_64-linux-gnu/libgcc_s.so.1 +--10897-- object doesn't have a symbol table +--10897-- Reading syms from /lib/x86_64-linux-gnu/libc-2.26.so +--10897-- Considering /lib/x86_64-linux-gnu/libc-2.26.so .. +--10897-- .. CRC mismatch (computed cc2bbe88 wanted e29f45fb) +--10897-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.26.so .. +--10897-- .. CRC is valid +--10897-- REDIR: 0x57c3ef0 (libc.so.6:memmove) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c2fb0 (libc.so.6:strncpy) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c41d0 (libc.so.6:strcasecmp) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c2a00 (libc.so.6:strcat) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c2fe0 (libc.so.6:rindex) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c5b50 (libc.so.6:rawmemchr) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c4060 (libc.so.6:mempcpy) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c3e80 (libc.so.6:bcmp) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c2f70 (libc.so.6:strncmp) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c2a70 (libc.so.6:strcmp) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c3fc0 (libc.so.6:memset) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57e1eb0 (libc.so.6:wcschr) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c2f10 (libc.so.6:strnlen) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c2ae0 (libc.so.6:strcspn) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c4220 (libc.so.6:strncasecmp) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c2ab0 (libc.so.6:strcpy) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c4360 (libc.so.6:memcpy@@GLIBC_2.14) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c3010 (libc.so.6:strpbrk) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c2a30 (libc.so.6:index) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c2ee0 (libc.so.6:strlen) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57ce4b0 (libc.so.6:memrchr) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c4270 (libc.so.6:strcasecmp_l) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c3e50 (libc.so.6:memchr) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57e2c60 (libc.so.6:wcslen) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c32f0 (libc.so.6:strspn) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c41a0 (libc.so.6:stpncpy) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c4170 (libc.so.6:stpcpy) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c5b80 (libc.so.6:strchrnul) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57c42c0 (libc.so.6:strncasecmp_l) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper) +--10897-- REDIR: 0x57d7100 (libc.so.6:__strrchr_sse2) redirected to 0x4c32790 (__strrchr_sse2) +--10897-- REDIR: 0x57bde90 (libc.so.6:malloc) redirected to 0x4c2faa0 (malloc) +--10897-- REDIR: 0x57d73f0 (libc.so.6:__strlen_sse2) redirected to 0x4c32d30 (__strlen_sse2) +--10897-- REDIR: 0x58af2a0 (libc.so.6:__memcmp_sse4_1) redirected to 0x4c35d50 (__memcmp_sse4_1) +--10897-- REDIR: 0x57cfc40 (libc.so.6:__strcmp_sse2_unaligned) redirected to 0x4c33da0 (strcmp) +--10897-- REDIR: 0x57e1230 (libc.so.6:memcpy@GLIBC_2.2.5) redirected to 0x4c34060 (memcpy@GLIBC_2.2.5) +--10897-- REDIR: 0x57c37f0 (libc.so.6:__GI_strstr) redirected to 0x4c37760 (__strstr_sse2) +--10897-- REDIR: 0x4ecc500 (libstdc++.so.6:operator new[](unsigned long)) redirected to 0x4c30830 (operator new[](unsigned long)) +--10897-- REDIR: 0x57e1210 (libc.so.6:__mempcpy_sse2_unaligned) redirected to 0x4c37130 (mempcpy) + add 0 938664 + add 0 174000 + get 1 + remove 1 + set 0 from 174000 to 110067 + set 0 from 110067 to 146670 + remove 0 + add 0 783067 + remove 0 + add 0 787688 + remove 0 + add 0 208428 + get 0 + add 0 798477 + set 1 from 208428 to 231693 + add 0 124053 + get 1 + remove 1 + get 0 + get 0 + add 0 366231 + get 0 + get 2 + remove 1 + add 0 962319 + remove 1 + add 0 643491 + remove 0 + remove 1 + add 0 1353 + add 0 861904 + get 0 + get 2 + get 1 + add 0 434933 + set 2 from 1353 to 348269 + add 3 433867 + remove 0 + get 1 + remove 3 + set 2 from 433867 to 530832 + add 1 437750 + remove 3 + get 0 + remove 2 + remove 1 + remove 0 + add 0 897006 + add 0 264521 + set 1 from 897006 to 615218 + remove 0 + add 0 282943 + remove 0 + add 0 918946 + add 1 515489 + remove 0 + get 1 + add 0 627902 + add 0 487162 + add 1 379320 + remove 3 + get 3 + add 0 656114 + add 4 374314 + set 2 from 379320 to 797736 + remove 4 + get 2 + get 0 + get 3 + remove 1 + remove 0 + set 1 from 627902 to 146677 + add 2 53559 + get 3 + remove 1 + remove 2 + get 1 + add 1 404915 + add 1 401525 + set 1 from 401525 to 109482 + set 1 from 109482 to 102964 + remove 1 + set 1 from 404915 to 143466 + set 0 from 797736 to 918583 + add 0 445767 + get 1 + set 0 from 445767 to 192591 + remove 1 + get 0 + get 0 + add 2 84076 + add 0 764044 + get 3 + add 3 55918 + set 3 from 55918 to 851755 + get 4 + set 0 from 764044 to 348149 + add 1 715971 + remove 1 + remove 4 + get 4 + add 3 6272 + set 5 from 53559 to 303294 + get 5 + add 3 235426 + remove 4 + add 2 405798 + set 1 from 192591 to 285431 +--10897-- REDIR: 0x4eca380 (libstdc++.so.6:operator delete(void*)) redirected to 0x4c311d0 (operator delete(void*)) +==10897== Mismatched free() / delete / delete [] +==10897== at 0x4C3123B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) +==10897== by 0x40692E: ods::SimpList::grow() (simplist.h:146) +==10897== by 0x406693: ods::SimpList::add(unsigned long, int) (simplist.h:94) +==10897== by 0x40297F: benchmark(ods::List&, int) (list_bench.cc:81) +==10897== by 0x4025F7: run(std::__cxx11::basic_string, std::allocator >, ods::List&, int) (list_bench.cc:108) +==10897== by 0x402395: main (list_bench.cc:128) +==10897== Address 0x5b20ef0 is 0 bytes inside a block of size 32 alloc'd +==10897== at 0x4C3089F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) +==10897== by 0x402DE3: ods::SimpList::SimpList() (simplist.h:34) +==10897== by 0x402350: main (list_bench.cc:127) +==10897== + add 6 320018 + remove 7 + add 3 815072 + add 1 216211 + remove 1 + remove 2 + add 6 992999 + remove 2 + set 2 from 143466 to 211984 + set 5 from 992999 to 244841 + get 2 + add 1 893599 + remove 2 + remove 1 + set 2 from 235426 to 388683 + add 0 195665 + set 3 from 388683 to 789864 + remove 5 + remove 1 + add 1 698456 + set 0 from 195665 to 495986 + add 3 662946 + remove 6 + remove 4 + set 0 from 495986 to 93238 + remove 1 + get 1 + get 0 + add 0 870667 + add 3 451832 + get 0 + get 5 + add 4 147505 + add 3 917471 + set 2 from 211984 to 169579 + remove 1 + remove 3 + get 1 + add 5 258618 + get 4 + remove 6 + set 5 from 258618 to 775753 + set 2 from 917471 to 48953 + remove 3 + add 1 145710 + remove 5 + add 4 144951 + get 3 + remove 1 + remove 2 + remove 2 + add 0 816627 + get 3 + add 2 745197 + add 2 745109 + remove 0 + set 3 from 169579 to 803380 + set 4 from 662946 to 262779 + get 1 + remove 0 + set 2 from 803380 to 836683 + remove 2 + remove 1 + add 0 740313 + add 0 261411 + remove 0 + add 1 137179 + remove 3 + get 1 + get 1 + remove 0 + remove 0 + set 0 from 745109 to 431294 + remove 0 + add 0 158044 + get 0 + set 0 from 158044 to 387605 + set 0 from 387605 to 399398 + set 0 from 399398 to 741105 + remove 0 + add 0 686932 + remove 0 + add 0 179188 + remove 0 + add 0 161134 + get 0 + set 0 from 161134 to 633158 + remove 0 + add 0 134008 + set 0 from 134008 to 379628 + add 0 287690 + get 0 + set 1 from 379628 to 42566 + add 1 832212 + set 2 from 42566 to 160396 + set 1 from 832212 to 345601 + add 0 997971 + remove 0 + set 0 from 287690 to 757917 + remove 0 + remove 0 + remove 0 + add 0 256379 + remove 0 + add 0 236437 + remove 0 + add 0 655722 + add 0 759208 + get 0 + add 0 661982 + get 0 + get 0 + add 0 244086 + get 1 + set 1 from 661982 to 739566 + get 1 + get 2 + add 1 730436 + set 4 from 655722 to 228717 + set 3 from 759208 to 474418 + set 1 from 730436 to 669436 + set 2 from 739566 to 298232 + set 4 from 228717 to 938861 + set 0 from 244086 to 168429 + set 3 from 474418 to 904167 + get 4 + remove 0 + add 1 901486 + remove 4 + remove 0 + set 0 from 901486 to 790175 + remove 0 + remove 0 + remove 0 + add 0 739764 + remove 0 + add 0 735319 + get 0 + set 0 from 735319 to 104915 + remove 0 + add 0 413771 + add 0 310870 + get 1 + add 0 624960 + set 0 from 624960 to 41902 + get 2 + remove 1 + get 1 + set 0 from 41902 to 246234 + remove 0 + get 0 + get 0 + get 0 + get 0 + add 0 128180 + get 1 + add 0 93939 + add 2 73632 + set 1 from 128180 to 426587 + remove 1 + add 0 172709 + add 0 944966 + add 0 557352 + get 5 + add 4 658870 + add 5 968491 + remove 7 + get 0 + add 6 528762 + get 4 + get 0 + remove 7 + remove 4 + get 5 + get 4 + remove 4 + get 4 + set 4 from 528762 to 16869 + remove 3 + add 2 538006 + add 2 999323 + get 0 + set 4 from 172709 to 623786 + set 2 from 999323 to 145071 + get 1 + set 1 from 944966 to 38958 + set 0 from 557352 to 221454 + remove 4 + add 1 742432 + add 4 388571 + set 2 from 38958 to 702643 + remove 1 + get 3 + get 4 + remove 2 + get 0 + set 1 from 702643 to 49545 + add 3 734539 + add 4 992015 + set 3 from 734539 to 460726 + set 5 from 538006 to 440761 + set 3 from 460726 to 464793 + add 4 602065 + add 1 736186 + get 6 + add 7 457991 + remove 8 + remove 6 + remove 3 + remove 0 + get 4 + remove 4 + set 0 from 736186 to 98896 + set 0 from 98896 to 312824 + add 1 355456 + add 3 766987 + add 2 115917 + remove 1 + add 0 769279 + set 4 from 766987 to 792404 + add 0 33477 + get 0 + add 2 745053 + remove 2 + add 1 419721 + add 3 286405 + get 10 + set 6 from 49545 to 595775 + set 8 from 464793 to 222312 + get 3 + remove 7 + remove 3 + get 5 + remove 6 + add 1 998795 + get 8 + set 8 from 16869 to 358662 + remove 2 + get 5 + get 5 + add 4 208739 + set 4 from 208739 to 182466 + set 6 from 595775 to 62860 + add 3 426867 + set 7 from 62860 to 293204 + remove 2 + set 2 from 426867 to 557736 + get 6 + get 8 + add 3 8823 + remove 5 + get 1 + add 5 557585 + remove 6 + set 8 from 358662 to 621839 + remove 7 + add 5 74016 + add 0 813767 + remove 0 + get 3 + remove 8 + get 2 + remove 7 + add 4 644331 + get 1 + get 1 + add 2 885783 + get 5 + get 3 + get 6 + add 2 369518 + add 4 965197 + set 3 from 885783 to 452564 + add 5 731741 + remove 4 + remove 10 + get 9 + get 9 + remove 9 + add 0 280252 + get 1 + get 2 + remove 2 + set 4 from 731741 to 744094 + remove 2 + set 0 from 280252 to 908203 + remove 3 + remove 6 + get 0 + add 4 752089 + get 0 + get 0 + remove 3 + get 4 + set 0 from 908203 to 274626 + get 0 + set 1 from 33477 to 139510 + remove 0 + remove 4 + get 3 + remove 2 + add 1 922889 + add 3 25012 + set 4 from 8823 to 388809 + remove 1 + get 3 + get 0 + remove 0 + remove 0 + set 1 from 388809 to 498287 + get 1 + get 1 + add 0 845435 + get 2 + remove 0 + remove 1 + set 0 from 25012 to 736911 + add 0 713212 + add 1 222186 + get 2 + set 2 from 736911 to 866974 + remove 2 + remove 0 + remove 0 + add 0 306606 + add 0 477920 + add 0 561540 + remove 0 + set 0 from 477920 to 745218 + set 1 from 306606 to 630184 + add 0 274271 + get 1 + remove 2 + get 0 + set 0 from 274271 to 631304 + get 1 + remove 0 + remove 0 + add 0 156216 + get 0 + set 0 from 156216 to 664258 + add 0 279862 + add 1 759073 + set 2 from 664258 to 729437 + get 0 + add 0 351391 + add 0 792460 + get 1 + add 0 321003 + set 3 from 279862 to 633133 + add 3 296166 + add 5 757459 + get 3 + get 5 + remove 3 + remove 3 + remove 1 + remove 2 + set 0 from 321003 to 105736 + add 0 955643 + add 1 15099 + get 0 + add 2 421798 + set 1 from 15099 to 478369 + remove 4 + get 1 + set 1 from 478369 to 811041 + get 5 + set 1 from 811041 to 673982 + remove 3 + get 3 + remove 2 + set 3 from 729437 to 678054 + remove 0 + set 1 from 759073 to 27286 + set 2 from 678054 to 74324 + get 1 + get 1 + set 0 from 673982 to 431386 + set 1 from 27286 to 340913 + get 0 + set 1 from 340913 to 976579 + get 0 + set 0 from 431386 to 248224 + get 1 + remove 2 + set 1 from 976579 to 70458 + get 0 + remove 0 + set 0 from 70458 to 7588 + add 0 703011 + remove 0 + get 0 + add 0 938666 + set 1 from 7588 to 382881 + get 1 + add 0 401983 + remove 1 + remove 0 + get 0 + add 0 301894 + add 1 49383 + set 1 from 49383 to 435042 + remove 2 + get 1 + add 0 146520 + remove 2 + set 1 from 301894 to 619526 + remove 1 + add 0 425274 + add 1 661004 + add 0 652132 + add 2 250801 + remove 2 + add 1 743064 + get 2 + remove 2 + set 3 from 146520 to 872064 + get 2 + set 1 from 743064 to 384351 + add 0 646485 + get 1 + add 4 286922 + remove 5 + remove 2 + add 0 263445 + get 0 + add 0 461346 + get 2 + set 3 from 652132 to 276548 + add 2 820291 + set 3 from 646485 to 35092 + get 4 + set 5 from 661004 to 718508 + get 5 + get 2 + add 4 784055 + remove 4 + remove 4 + get 1 + set 4 from 718508 to 318545 + set 2 from 820291 to 867334 + get 5 + add 0 514903 + remove 4 + add 2 652633 + get 3 + add 4 743505 + add 1 18386 + set 2 from 461346 to 423392 + add 6 94512 + get 1 + set 8 from 318545 to 566704 + add 5 676849 + remove 1 + remove 2 + set 2 from 263445 to 684401 + add 5 425380 + get 4 + remove 8 + set 1 from 423392 to 262632 + set 0 from 514903 to 485214 + get 7 + remove 7 + remove 2 + get 2 + add 6 47907 + get 7 + remove 3 + set 2 from 676849 to 911446 + remove 5 + remove 2 + set 0 from 485214 to 570397 + remove 3 + add 3 942894 + set 4 from 286922 to 18052 + remove 1 + add 3 701745 + get 0 + get 1 + remove 0 + remove 1 + get 1 + remove 1 + remove 1 + set 0 from 425380 to 172072 + get 0 + get 0 + get 0 + add 0 698776 + remove 1 + remove 0 + add 0 994985 + remove 0 + add 0 357837 + set 0 from 357837 to 243482 + remove 0 + add 0 265166 + get 0 + remove 0 + add 0 572441 + set 0 from 572441 to 962978 + add 0 550295 + get 0 + remove 1 + set 0 from 550295 to 45406 + add 0 411940 + remove 1 + get 0 + set 0 from 411940 to 230771 + add 0 740683 + set 1 from 230771 to 671431 + remove 1 + get 0 + add 0 116072 + set 1 from 740683 to 393223 + set 1 from 393223 to 488951 + add 1 599762 + add 1 828243 + add 3 831911 + get 0 + remove 4 + remove 1 + set 2 from 831911 to 771098 + add 1 406813 + add 1 748131 + get 3 + set 2 from 406813 to 646830 + set 0 from 116072 to 130184 + get 2 + remove 4 + get 1 + add 2 270246 + add 1 303019 + add 5 171232 + remove 0 + set 4 from 171232 to 915783 + get 3 + set 2 from 270246 to 174010 + get 1 + get 2 + get 0 + set 2 from 174010 to 995332 + set 3 from 646830 to 730660 + get 4 + get 1 + set 1 from 748131 to 506953 + set 0 from 303019 to 247994 + set 5 from 599762 to 503893 + set 1 from 506953 to 312755 + get 0 + remove 3 + add 0 164892 + remove 2 + remove 0 + set 3 from 503893 to 649270 + get 3 + add 2 805665 + add 2 281184 + remove 1 + set 4 from 649270 to 528410 + set 3 from 915783 to 935036 + set 4 from 528410 to 909887 + remove 2 + set 3 from 909887 to 873691 + remove 3 + remove 1 + set 1 from 935036 to 308614 + remove 0 + add 0 827934 + add 1 890587 + remove 1 + set 1 from 308614 to 317207 + remove 1 + add 0 18279 + get 1 + get 0 + set 0 from 18279 to 218601 + set 1 from 827934 to 958925 + remove 1 + get 0 + remove 0 + add 0 746804 + remove 0 + add 0 242988 + remove 0 + add 0 90598 + add 0 855062 + add 0 325760 + remove 0 + add 0 737827 + remove 0 + set 0 from 855062 to 229589 + get 0 + get 0 + add 0 298786 + remove 0 + get 1 + remove 0 + get 0 + set 0 from 90598 to 352204 + set 0 from 352204 to 884174 + remove 0 + add 0 830824 + get 0 + get 0 + get 0 + get 0 + set 0 from 830824 to 323409 + add 0 408282 + set 0 from 408282 to 316390 + add 1 970924 + get 1 + remove 1 + get 1 + get 1 + set 1 from 323409 to 682475 + set 0 from 316390 to 674622 + remove 0 + remove 0 + add 0 987751 + add 0 827466 + set 1 from 987751 to 940034 + remove 0 + get 0 + get 0 + get 0 + get 0 + add 0 710850 + remove 0 + add 0 11958 + add 1 958282 + get 2 + get 1 + set 1 from 958282 to 911493 + set 0 from 11958 to 25181 + get 1 + set 0 from 25181 to 364579 + set 0 from 364579 to 560492 + get 2 + add 0 34809 + set 2 from 911493 to 893500 + remove 3 + get 1 + set 1 from 560492 to 29876 + add 2 673772 + get 0 + get 2 + get 0 + remove 2 + remove 1 + add 0 810477 + get 0 + add 1 601059 + get 0 + get 2 + get 0 + get 3 + set 1 from 601059 to 414238 + get 1 + set 0 from 810477 to 608461 + remove 3 + set 0 from 608461 to 497850 + get 0 + set 1 from 414238 to 112713 + get 1 + get 2 + add 1 639742 + remove 0 + add 0 85237 + set 1 from 639742 to 902788 + add 0 200332 + add 3 626001 + set 3 from 626001 to 576098 + get 3 + get 0 + add 2 52131 + add 0 669127 + add 7 933391 + remove 6 + get 4 + remove 3 + get 0 + add 2 253704 + add 6 820057 + add 0 284937 + set 8 from 933391 to 749102 + set 0 from 284937 to 600073 + remove 2 + set 1 from 669127 to 541531 + remove 8 + remove 2 + remove 5 + add 0 641808 + add 5 682015 + set 6 from 576098 to 81318 + add 6 443502 + get 3 + add 2 322495 + remove 9 + set 1 from 600073 to 742566 + set 4 from 85237 to 859593 + set 6 from 682015 to 245890 + add 5 907110 + set 5 from 907110 to 600110 + set 5 from 600110 to 416000 + set 8 from 443502 to 324552 + set 7 from 245890 to 233987 + add 0 769864 + remove 6 + set 7 from 233987 to 91388 + add 4 298155 + set 6 from 859593 to 448393 + get 6 + remove 8 + add 2 275629 + remove 3 + get 3 + set 6 from 448393 to 663661 + add 8 468837 + remove 5 + remove 7 + add 6 23048 + remove 3 + remove 4 + remove 2 + get 3 + remove 5 + get 5 + add 3 933624 + add 0 166523 + set 3 from 298155 to 340306 + add 1 502012 + get 3 + set 6 from 23048 to 120180 + set 2 from 769864 to 95683 + remove 6 + get 6 + get 7 + remove 2 + remove 5 + add 2 81171 + get 4 + get 4 + set 4 from 340306 to 902176 + add 6 833802 + set 3 from 641808 to 985483 + remove 3 + get 2 + remove 1 + remove 2 + remove 0 + add 2 351671 + remove 2 + add 3 235056 + get 1 + get 3 + get 2 + add 3 682696 + add 4 708425 + add 0 182443 + remove 2 + remove 4 + add 4 480914 + remove 2 + get 3 + add 2 771126 + remove 6 + get 4 + set 0 from 182443 to 425556 + remove 0 + set 1 from 771126 to 377671 + set 0 from 81171 to 150420 + remove 2 + add 3 274140 + set 4 from 235056 to 271836 + get 3 + set 4 from 271836 to 565234 + remove 4 + set 0 from 150420 to 211126 + set 0 from 211126 to 772636 + get 2 + set 3 from 274140 to 235098 + get 3 + remove 2 + set 0 from 772636 to 215658 + set 2 from 235098 to 155744 + add 2 570655 + remove 2 + set 2 from 155744 to 625033 + remove 1 + get 1 + set 1 from 625033 to 527945 + add 1 103025 + add 1 947006 + add 0 278487 + set 1 from 215658 to 588232 + add 3 421465 + set 4 from 103025 to 42735 + add 3 513704 + get 4 + add 0 67377 + add 7 420527 + add 7 230684 + remove 5 + set 5 from 42735 to 217721 + remove 3 + set 0 from 67377 to 988106 + get 2 + add 1 881063 + get 7 + add 0 107367 + add 0 862189 + remove 10 + remove 8 + set 4 from 278487 to 792994 + set 1 from 107367 to 716978 + get 7 + remove 0 + get 2 + set 6 from 217721 to 481142 + get 0 + set 1 from 988106 to 135547 + remove 1 + get 1 + add 3 922973 + add 0 388761 + remove 3 + get 1 + remove 7 + remove 5 + set 4 from 588232 to 367235 + add 0 94301 + remove 5 + remove 5 + add 1 255203 + add 3 95318 + remove 2 + get 5 + add 3 386778 + get 4 + add 3 138406 + remove 4 + add 0 368584 + add 3 970352 + set 8 from 922973 to 115887 + add 0 283579 + get 1 + remove 7 + add 3 819453 + get 4 + set 0 from 283579 to 228003 + remove 8 + add 4 152082 + remove 4 + remove 3 + add 7 674103 + add 7 348757 + set 2 from 94301 to 824907 + remove 5 + add 8 939617 + remove 1 + remove 3 + set 4 from 348757 to 416249 + set 5 from 674103 to 518497 + set 1 from 824907 to 262080 + set 5 from 518497 to 203925 + get 3 + get 3 + get 7 + get 6 + set 5 from 203925 to 707699 + set 4 from 416249 to 156779 + remove 4 + remove 4 + set 5 from 115887 to 901760 + remove 2 + remove 4 + get 3 + set 3 from 939617 to 652217 + get 1 + remove 2 + remove 2 + remove 1 + remove 0 + add 0 208464 + set 0 from 208464 to 7907 + add 0 419892 + set 0 from 419892 to 130849 + add 1 360072 + remove 0 + add 0 919076 +SimpList @ 1000 ops: --10897-- REDIR: 0x57d6ef0 (libc.so.6:__strchrnul_sse2) redirected to 0x4c37020 (strchrnul) +--10897-- REDIR: 0x57d1740 (libc.so.6:__memchr_sse2) redirected to 0x4c33f80 (memchr) +0.186746s +--10897-- REDIR: 0x4ecc440 (libstdc++.so.6:operator new(unsigned long)) redirected to 0x4c30110 (operator new(unsigned long)) + add 0 154151 + set 0 from 154151 to 403671 + get 0 + remove 0 + add 0 570198 + set 0 from 570198 to 754024 + get 0 + set 0 from 754024 to 91950 + set 0 from 91950 to 11041 + get 0 + set 0 from 11041 to 236041 + remove 0 + add 0 374963 + set 0 from 374963 to 263334 + add 0 155924 + remove 0 + remove 0 + add 0 389853 + get 0 + add 0 797009 + remove 0 + get 0 + add 0 903056 + add 1 954683 + remove 0 + set 1 from 389853 to 676810 + remove 1 + add 0 132109 + add 0 665090 + set 2 from 954683 to 953063 + get 0 + add 2 71476 + set 1 from 132109 to 717903 + add 2 379790 + get 0 + get 0 + remove 0 + remove 1 + remove 1 + add 0 279339 + get 0 + set 2 from 953063 to 78412 + set 1 from 717903 to 779595 + add 1 442921 + add 0 728040 + add 0 227086 + set 5 from 78412 to 427351 + remove 3 + get 4 + remove 4 + remove 2 + set 0 from 227086 to 840258 + get 2 + add 2 949244 + set 1 from 728040 to 637353 + get 3 + set 0 from 840258 to 443921 + add 3 659653 + add 4 291211 + get 0 + remove 1 + get 1 + get 0 + add 0 96197 + add 1 393155 + remove 2 + add 0 257290 + remove 4 + add 3 851658 + remove 1 + add 1 292153 + set 3 from 851658 to 651639 + get 3 + remove 4 + get 4 + remove 4 + get 2 + remove 1 + remove 0 + remove 1 + set 1 from 779595 to 490655 + set 1 from 490655 to 109629 + set 0 from 393155 to 958863 + remove 0 + set 0 from 109629 to 578969 + add 0 99436 + get 1 + add 1 889504 + add 1 94769 + add 0 688293 + set 2 from 94769 to 936513 + get 3 + add 4 100684 + set 0 from 688293 to 765185 + remove 0 + get 4 + add 1 763991 + remove 3 + add 1 67862 + get 5 + remove 5 + remove 1 + set 3 from 100684 to 715633 + remove 3 + set 0 from 99436 to 353308 + get 2 + remove 1 + remove 1 + add 0 287101 + get 0 + set 0 from 287101 to 618133 + add 0 290531 + set 1 from 618133 to 510122 + get 1 + set 2 from 353308 to 60653 + set 0 from 290531 to 737314 + set 0 from 737314 to 472289 + remove 2 + remove 1 + set 0 from 472289 to 387131 + remove 0 + add 0 176910 + set 0 from 176910 to 60793 + remove 0 + add 0 198401 + remove 0 + add 0 867568 + set 0 from 867568 to 15875 + get 0 + get 0 + set 0 from 15875 to 511698 + remove 0 + add 0 870698 + remove 0 + add 0 896151 + add 0 7532 + add 0 109630 + add 2 630413 + set 1 from 7532 to 199637 + set 0 from 109630 to 27632 + get 2 + add 0 461381 + set 3 from 630413 to 79717 + add 1 242939 + remove 3 + set 1 from 242939 to 99023 + set 2 from 27632 to 96216 + get 1 + add 1 640894 + remove 4 + add 0 760565 + remove 2 + get 4 + add 1 466911 + remove 5 + get 3 + remove 4 + add 3 908137 + remove 4 + get 2 + set 2 from 461381 to 350953 + add 2 250457 + remove 3 + get 2 + remove 3 + remove 0 + add 0 424108 + set 2 from 250457 to 775341 + set 2 from 775341 to 2469 + remove 2 + add 1 633914 + remove 0 + set 0 from 633914 to 339713 + set 0 from 339713 to 236603 + set 1 from 466911 to 316804 + add 0 312589 + add 2 372981 + set 1 from 236603 to 176743 + set 0 from 312589 to 616101 + remove 1 + set 0 from 616101 to 154543 + get 0 + add 0 91614 + remove 2 + remove 0 + get 1 + remove 1 + set 0 from 154543 to 244078 + remove 0 + add 0 838417 + remove 0 + add 0 205932 + set 0 from 205932 to 116255 + get 0 + add 0 926097 + add 1 697799 + add 1 749964 + set 3 from 116255 to 264351 + remove 1 + get 2 + set 2 from 264351 to 80093 + remove 1 + remove 0 + remove 0 + add 0 370351 + get 0 + set 0 from 370351 to 40802 + add 0 626846 + add 1 731409 + set 1 from 731409 to 735340 + get 1 + get 1 + remove 2 + remove 0 + remove 0 + add 0 227123 + remove 0 + add 0 698120 + remove 0 + add 0 325469 + add 0 148967 + set 0 from 148967 to 757339 + get 1 + set 0 from 757339 to 89752 + set 1 from 325469 to 603744 + add 0 186415 + add 1 188764 + add 1 426638 + get 2 + remove 4 + remove 1 + get 2 + remove 0 + get 1 + add 0 803790 + set 0 from 803790 to 673341 + remove 0 + remove 1 + add 0 814256 + add 0 738780 + set 0 from 738780 to 95984 + set 0 from 95984 to 264791 + get 2 + remove 2 + set 1 from 814256 to 351151 + remove 0 + remove 0 + add 0 205171 + set 0 from 205171 to 212024 + remove 0 + add 0 321255 + add 0 658861 + set 1 from 321255 to 853331 + set 1 from 853331 to 110391 + set 1 from 110391 to 156705 + set 1 from 156705 to 398960 + remove 0 + get 0 + add 0 437268 + remove 1 + remove 0 + add 0 967610 + get 0 + remove 0 + add 0 927168 + set 0 from 927168 to 980290 + remove 0 + add 0 829076 + get 0 + set 0 from 829076 to 924639 + get 0 + add 0 670419 + add 1 123247 + remove 1 + set 0 from 670419 to 319405 + set 1 from 924639 to 470606 + set 0 from 319405 to 16156 + get 0 + remove 0 + get 0 + add 0 938092 + remove 1 + get 0 + get 0 + add 0 11821 + get 0 + get 0 + get 1 + get 1 + get 0 + get 1 + remove 1 + add 0 240342 + remove 0 + set 0 from 11821 to 487589 + set 0 from 487589 to 733605 + set 0 from 733605 to 446268 + remove 0 + add 0 335596 + remove 0 + add 0 668891 + remove 0 + add 0 862330 + remove 0 + add 0 658079 + get 0 + get 0 + set 0 from 658079 to 804643 + add 0 368433 + get 1 + get 0 + add 1 81648 + add 2 171151 + remove 2 + get 2 + set 1 from 81648 to 901347 + remove 1 + remove 0 + add 0 659024 + set 0 from 659024 to 553521 + set 1 from 804643 to 995195 + add 0 655918 + get 0 + add 0 797923 + remove 3 + get 1 + set 2 from 553521 to 224439 + get 2 + set 2 from 224439 to 361531 + remove 0 + remove 1 + set 0 from 655918 to 58931 + add 0 268892 + add 0 999011 + get 1 + set 0 from 999011 to 706246 + get 2 + add 0 785270 + add 0 225109 + get 1 + get 3 + add 0 481412 + remove 5 + remove 4 + set 0 from 481412 to 617308 + remove 2 + set 2 from 706246 to 198840 + get 2 + set 0 from 617308 to 753901 + remove 2 + add 1 149440 + add 1 32610 + remove 2 + get 1 + get 0 + set 2 from 225109 to 545547 + get 2 + add 2 205897 + remove 0 + get 2 + set 0 from 32610 to 319987 + remove 1 + set 0 from 319987 to 586906 + get 1 + get 0 + set 1 from 545547 to 514035 + add 1 468159 + add 2 262353 + remove 2 + get 1 + set 1 from 468159 to 885692 + add 2 265567 + remove 3 + add 2 949676 + add 1 554687 + get 3 + remove 2 + remove 0 + remove 2 + add 0 236345 + set 1 from 554687 to 807881 + add 0 821076 + get 2 + set 3 from 949676 to 162277 + set 2 from 807881 to 262292 + get 1 + add 0 100009 + add 2 293125 + set 2 from 293125 to 400912 + set 4 from 262292 to 871885 + add 5 88557 + remove 0 + set 1 from 400912 to 996856 + get 5 + add 0 442727 + add 3 440312 + get 2 + remove 6 + set 6 from 162277 to 389899 + get 6 + remove 6 + get 2 + set 0 from 442727 to 988956 + get 0 + remove 5 + set 1 from 821076 to 918389 + add 3 216904 + remove 0 + set 1 from 996856 to 749090 + add 4 882130 + add 5 802659 + get 2 + set 5 from 802659 to 980849 + remove 2 + add 5 305675 + get 2 + set 0 from 918389 to 495840 + set 5 from 305675 to 292663 + get 3 + add 3 988228 + set 0 from 495840 to 280566 + set 3 from 988228 to 819125 + remove 5 + remove 2 + set 5 from 236345 to 114126 + get 0 + set 4 from 292663 to 378674 + get 1 + remove 3 + set 1 from 749090 to 325702 + add 1 73596 + add 5 995279 + add 1 245273 + set 6 from 995279 to 254121 + set 7 from 114126 to 539538 + set 0 from 280566 to 682010 + add 1 398751 + add 2 263233 + set 0 from 682010 to 215820 + get 0 + set 7 from 378674 to 789885 + remove 8 + set 0 from 215820 to 42718 + remove 8 + remove 2 + add 0 205991 + remove 1 + set 6 from 789885 to 802792 + add 0 187620 + add 1 82605 + add 7 146381 + set 7 from 146381 to 707236 + set 6 from 325702 to 998766 + get 8 + add 0 197916 + get 1 + add 4 164845 + get 11 + get 4 + remove 7 + add 2 794869 + remove 1 + set 6 from 245273 to 846759 + remove 9 + remove 4 + get 5 + remove 2 + remove 6 + add 0 833586 + set 7 from 802792 to 664948 + get 3 + remove 6 + add 4 246422 + add 4 787559 + add 3 691396 + set 2 from 794869 to 576763 + remove 5 + remove 2 + get 2 + get 7 + get 5 + add 6 306077 + set 8 from 664948 to 325967 + remove 7 + add 1 917490 + set 5 from 246422 to 364436 + add 3 252679 + remove 7 + set 4 from 691396 to 630581 + get 7 + get 8 + remove 5 + add 7 259184 + add 1 28641 + remove 7 + get 3 + set 0 from 833586 to 682404 + add 5 917165 + set 6 from 630581 to 309979 + get 3 + remove 6 + get 6 + get 4 + remove 4 + get 2 + set 3 from 197916 to 947736 + add 1 637047 + get 8 + set 6 from 364436 to 143889 + remove 8 + get 0 + remove 1 + get 5 + set 6 from 259184 to 483743 + get 0 + set 3 from 947736 to 528678 + get 3 + remove 0 + set 2 from 528678 to 676701 + remove 2 + get 4 + get 3 + set 0 from 28641 to 472972 + remove 2 + remove 0 + add 0 388329 + remove 2 + get 0 + get 2 + remove 0 + get 1 + set 1 from 483743 to 91691 + remove 1 + set 0 from 917490 to 120038 + get 0 + remove 0 + add 0 715637 + add 0 729853 + remove 0 + remove 0 + add 0 969938 + remove 0 + add 0 75152 + set 0 from 75152 to 67621 + set 0 from 67621 to 136339 + get 0 + set 0 from 136339 to 568512 + set 0 from 568512 to 844196 + set 0 from 844196 to 368194 + remove 0 + add 0 814387 + get 0 + add 0 681921 + remove 1 + set 0 from 681921 to 549003 + add 0 104691 + get 0 + get 1 + get 1 + set 1 from 549003 to 148123 + set 1 from 148123 to 587984 + add 0 399735 + set 1 from 104691 to 274527 + remove 1 + get 1 + add 0 985970 + remove 2 + remove 0 + add 0 441426 + set 0 from 441426 to 788578 + remove 0 + get 0 + add 0 951494 + remove 0 + get 0 + remove 0 + add 0 91627 + add 0 336429 + remove 1 + get 0 + remove 0 + add 0 174079 + add 0 735456 + add 1 689966 + remove 2 + add 0 754283 + remove 0 + set 1 from 689966 to 884639 + get 1 + get 1 + get 1 + get 1 + add 1 260204 + add 0 100752 + remove 1 + set 2 from 884639 to 111357 + remove 1 + add 1 578076 + get 1 + remove 1 + set 1 from 111357 to 730505 + add 0 351703 + remove 2 + add 1 674174 + set 1 from 674174 to 388126 + add 1 94101 + remove 3 + set 2 from 388126 to 93202 + remove 0 + remove 1 + get 0 + remove 0 + add 0 539088 + set 0 from 539088 to 366313 + get 0 + remove 0 + add 0 526473 + remove 0 + add 0 500639 + remove 0 + add 0 67157 + set 0 from 67157 to 134694 + add 0 128984 + add 1 459321 + set 0 from 128984 to 613355 + set 2 from 134694 to 406489 + remove 0 + remove 0 + add 0 43881 + get 0 + get 0 + get 1 + set 1 from 406489 to 882451 + add 1 489501 + add 2 292488 + remove 1 + get 2 + set 1 from 292488 to 952744 + get 1 + get 1 + set 2 from 882451 to 782806 + get 0 + add 1 532092 + get 1 + set 3 from 782806 to 524874 + get 2 + add 1 714633 + remove 0 + set 0 from 714633 to 92689 + set 3 from 524874 to 44396 + add 1 149992 + remove 3 + remove 2 + get 2 + get 1 + add 0 610192 + get 2 + set 2 from 149992 to 365773 + set 2 from 365773 to 808040 + set 0 from 610192 to 821357 + remove 0 + remove 2 + get 0 + get 0 + remove 1 + get 0 + set 0 from 92689 to 380952 + remove 0 + add 0 867823 + remove 0 + add 0 315875 + set 0 from 315875 to 725795 + remove 0 + add 0 514612 + set 0 from 514612 to 519250 + get 0 + get 0 + get 0 + add 0 299454 + set 0 from 299454 to 982105 + add 0 514921 + set 0 from 514921 to 564479 + remove 2 + get 1 + add 1 407098 + get 1 + remove 1 + get 0 + add 1 729042 + add 0 321505 + remove 1 + remove 0 + remove 0 + get 0 + set 0 from 982105 to 148309 + remove 0 + add 0 720693 + set 0 from 720693 to 546900 + add 0 460265 + add 0 50462 + get 2 + add 2 68847 + set 1 from 460265 to 990264 + set 1 from 990264 to 896072 + get 0 + add 2 686072 + add 2 651209 + get 2 + remove 5 + get 1 + add 3 338500 + get 5 + add 3 330172 + get 3 + get 3 + set 6 from 68847 to 502261 + add 6 183834 + remove 3 + get 5 + set 5 from 183834 to 644961 + set 6 from 502261 to 458026 + add 3 103946 + remove 0 + remove 1 + set 0 from 896072 to 193799 + set 2 from 338500 to 218732 + add 2 84061 + add 3 128413 + get 5 + add 2 645502 + set 0 from 193799 to 575175 + get 4 + set 7 from 644961 to 147804 + add 4 633266 + add 1 219752 + set 7 from 218732 to 980634 + add 8 563429 + remove 7 + remove 1 + add 1 379317 + get 9 + set 4 from 84061 to 434276 + get 2 + set 6 from 128413 to 814642 + get 5 + remove 0 + remove 3 + remove 7 + get 5 + add 7 44430 + add 5 188260 + remove 1 + get 5 + set 7 from 44430 to 579204 + set 1 from 645502 to 31645 + remove 7 + remove 4 + set 0 from 379317 to 765394 + get 4 + remove 0 + set 5 from 458026 to 215811 + get 5 + set 4 from 686072 to 802086 + add 3 826576 + set 3 from 826576 to 999215 + set 6 from 215811 to 27773 + add 2 609480 + set 4 from 999215 to 645828 + get 2 + set 5 from 563429 to 933071 + add 5 140688 + remove 4 + remove 0 + set 0 from 633266 to 83606 + remove 4 + set 0 from 83606 to 931887 + add 4 417233 + remove 1 + add 2 77109 + add 0 828067 + add 2 4451 + set 2 from 4451 to 375077 + remove 3 + remove 5 + remove 0 + set 5 from 27773 to 640729 + set 3 from 140688 to 22840 + set 2 from 77109 to 425853 + set 0 from 931887 to 165682 + remove 3 + remove 0 + add 1 531883 + set 1 from 531883 to 52075 + remove 2 + add 0 346438 + set 1 from 375077 to 776878 + get 0 + set 3 from 802086 to 313510 + get 1 + get 0 + remove 0 + remove 2 + get 2 + add 2 300282 + remove 0 + set 0 from 52075 to 624208 + add 2 498916 + add 3 648758 + remove 0 + add 3 780580 + get 3 + get 1 + set 1 from 498916 to 780632 + set 2 from 648758 to 48025 + add 1 826047 + set 1 from 826047 to 172053 + add 1 1230 + remove 3 + remove 2 + set 3 from 780580 to 504861 + set 0 from 300282 to 569553 + set 2 from 48025 to 486047 + get 3 + remove 0 + get 1 + set 3 from 640729 to 523918 + get 1 + set 0 from 1230 to 472491 + remove 3 + get 1 + add 0 944605 + remove 3 + add 1 924966 + remove 1 + set 2 from 486047 to 848632 + add 0 902987 + get 2 + add 0 545933 + set 2 from 944605 to 596506 + add 3 370922 + get 2 + set 3 from 370922 to 677823 + get 4 + add 1 830800 + set 4 from 677823 to 18123 + get 5 + remove 3 + add 4 90130 + remove 1 + get 1 + add 1 853784 + remove 2 + set 0 from 545933 to 914256 + add 0 454939 + set 1 from 914256 to 644756 + get 3 + add 5 34935 + add 6 713431 + get 7 + set 4 from 90130 to 533172 + remove 7 + add 7 297570 + get 4 + set 0 from 454939 to 209766 + set 5 from 34935 to 237232 + remove 6 + remove 2 + add 0 463628 + remove 4 + get 6 + set 4 from 237232 to 313923 + set 6 from 848632 to 225243 + add 5 923983 + remove 2 + get 5 + add 6 30657 + remove 5 + remove 2 + remove 2 + set 0 from 463628 to 905675 + add 1 189882 + remove 2 + add 4 709465 + add 3 49808 + add 1 328726 + get 2 + set 7 from 225243 to 947909 + set 0 from 905675 to 191311 + add 4 980315 + set 2 from 189882 to 193930 + remove 4 + get 2 + set 0 from 191311 to 524871 + add 1 33115 + set 5 from 49808 to 468967 + get 5 + set 3 from 193930 to 9890 + get 4 + set 8 from 947909 to 623960 + get 4 + set 2 from 328726 to 522427 + add 3 753926 + get 1 + set 6 from 468967 to 878239 + remove 2 + get 2 + set 5 from 878239 to 950449 + set 4 from 923983 to 508862 + remove 6 + add 0 795584 + set 3 from 753926 to 478987 + set 3 from 478987 to 748170 + remove 0 + remove 1 + set 6 from 623960 to 483998 + add 5 635721 + remove 0 + get 1 + get 3 + add 1 27924 + add 7 256907 + set 2 from 9890 to 372119 + remove 1 + remove 5 + set 0 from 748170 to 446551 + add 1 878127 + remove 5 + add 6 847911 + add 2 146350 + set 3 from 372119 to 501953 + remove 1 + get 5 + remove 3 + set 3 from 950449 to 928127 + remove 4 + set 3 from 928127 to 160432 + add 3 652753 + set 5 from 847911 to 716640 + set 2 from 501953 to 126686 + get 4 + add 4 247065 + set 6 from 716640 to 531321 + set 1 from 146350 to 946420 + add 0 732958 + remove 1 + remove 0 + set 1 from 126686 to 42884 + add 0 349092 + remove 1 + get 2 + set 0 from 349092 to 104518 + get 3 + add 3 96685 + get 6 + set 7 from 483998 to 644295 + get 1 + get 7 + get 0 + add 0 316381 + add 3 658150 + add 1 542911 + remove 3 + add 4 777501 + add 10 138278 + get 5 + add 9 916846 + set 2 from 104518 to 434097 + add 10 114710 + get 4 + remove 11 + add 10 827585 + set 3 from 658150 to 480104 + get 2 + remove 9 + remove 2 + remove 4 + add 4 327747 + set 8 from 827585 to 72396 + remove 2 + remove 10 + remove 9 + remove 1 + get 2 + add 2 437280 + get 5 + get 8 + add 6 865943 + remove 6 + get 1 + remove 1 + remove 3 + remove 1 + get 1 + set 1 from 327747 to 606271 + set 5 from 114710 to 216521 + set 1 from 606271 to 918947 + set 4 from 72396 to 622784 + add 0 962541 + remove 1 + get 0 +VList @ 1000 ops: 0.228199s + add 0 574040 + set 0 from 574040 to 284392 + remove 0 + add 0 955753 + get 0 + set 0 from 955753 to 491913 + set 0 from 491913 to 409808 + remove 0 + add 0 981960 + remove 0 + add 0 488446 + set 0 from 488446 to 945070 + add 0 637827 + get 1 + remove 0 + get 0 + get 0 + get 0 + set 0 from 945070 to 40826 + add 0 51237 + set 0 from 51237 to 617729 + set 0 from 617729 to 307712 + get 0 + set 1 from 40826 to 865761 + get 1 + add 0 84567 + get 1 + remove 0 + remove 0 + get 0 + add 0 254597 + add 1 631668 + get 2 + set 1 from 631668 to 354540 + get 0 + set 1 from 354540 to 95574 + add 1 93919 + add 0 527243 + add 3 562781 + remove 5 + set 2 from 93919 to 661471 + remove 4 + add 2 296536 + remove 4 + set 1 from 254597 to 794681 + get 1 + set 3 from 661471 to 846516 + set 2 from 296536 to 153246 + remove 0 + get 1 + remove 2 + get 1 + remove 0 + remove 0 + add 0 685154 + remove 0 + add 0 86725 + get 0 + add 0 640178 + add 1 398629 + add 1 556920 + remove 1 + get 2 + get 0 + add 1 64403 + set 2 from 398629 to 750967 + set 2 from 750967 to 177366 + set 2 from 177366 to 479717 + remove 1 + set 1 from 479717 to 532423 + get 1 + remove 0 + get 0 + add 0 52232 + set 0 from 52232 to 660953 + remove 0 + add 0 397553 + set 2 from 86725 to 77193 + set 1 from 532423 to 83480 + get 1 + set 2 from 77193 to 413474 + get 2 + get 1 + add 0 40379 + set 1 from 397553 to 30352 + add 1 549515 + remove 1 + add 1 526253 + get 3 + add 0 980618 + add 5 374387 + add 3 331996 + get 2 + set 1 from 40379 to 662072 + get 6 + remove 3 + remove 4 + add 0 215929 + add 3 142047 + set 0 from 215929 to 779780 + get 3 + add 4 494448 + remove 8 + add 5 206649 + remove 0 + remove 4 + get 4 + remove 4 + get 5 + remove 4 + set 1 from 662072 to 732188 + remove 1 + get 1 + remove 1 + remove 1 + add 0 41027 + remove 2 + remove 0 + remove 0 + add 0 843587 + set 0 from 843587 to 800160 + remove 0 + add 0 851731 + remove 0 + add 0 157574 + set 0 from 157574 to 151827 + get 0 + get 0 + remove 0 + add 0 805420 + set 0 from 805420 to 483953 + add 0 607102 + set 1 from 483953 to 726890 + add 0 405194 + add 0 853433 + add 0 575180 + add 1 148084 + remove 0 + set 0 from 148084 to 755834 + set 2 from 405194 to 207756 + add 2 749441 + set 2 from 749441 to 457288 + get 3 + remove 3 + add 4 105249 + add 2 362097 + set 3 from 457288 to 449574 + set 5 from 105249 to 471204 + get 3 + add 5 529178 + remove 0 + add 0 154173 + get 1 + get 5 + get 1 + add 1 713336 + add 4 488197 + get 5 + remove 5 + remove 3 + get 1 + add 3 945244 + set 2 from 853433 to 281955 + get 3 + get 4 + get 0 + get 6 + set 1 from 713336 to 743726 + remove 6 + set 3 from 945244 to 438947 + set 6 from 471204 to 203300 + add 2 102442 + set 7 from 203300 to 227945 + get 2 + remove 6 + add 1 558277 + set 1 from 558277 to 760078 + remove 3 + set 4 from 438947 to 157643 + get 0 + add 1 640662 + set 3 from 743726 to 517513 + set 2 from 760078 to 581839 + set 4 from 281955 to 292827 + set 3 from 517513 to 31687 + add 1 339377 + remove 6 + get 0 + get 7 + set 8 from 726890 to 442899 + add 2 647950 + get 2 + get 1 + set 5 from 31687 to 899132 + remove 4 + set 3 from 640662 to 266439 + remove 6 + remove 4 + add 1 325134 + remove 5 + add 5 686149 + remove 4 + get 6 + add 3 202196 + add 1 90916 + remove 2 + get 1 + set 2 from 339377 to 760019 + remove 7 + add 5 852952 + remove 4 + set 5 from 686149 to 542671 + set 0 from 154173 to 503341 + remove 2 + get 4 + set 3 from 852952 to 420424 + set 2 from 202196 to 851745 + remove 3 + get 4 + set 3 from 542671 to 209582 + set 3 from 209582 to 759815 + add 3 580690 + get 2 + get 3 + get 4 + set 0 from 503341 to 127075 + add 2 817759 + get 5 + remove 5 + set 3 from 851745 to 180882 + remove 5 + set 2 from 817759 to 790678 + get 2 + get 3 + remove 2 + add 3 240272 + add 2 963612 + add 4 239866 + remove 5 + remove 1 + get 3 + add 0 434440 + get 0 + get 5 + get 0 + get 1 + remove 3 + get 3 + add 2 639948 + add 2 640888 + get 2 + add 5 314295 + set 2 from 640888 to 606178 + set 2 from 606178 to 116030 + get 4 + add 1 896351 + add 5 912422 + get 8 + get 5 + get 3 + get 2 + add 4 440109 + remove 7 + set 6 from 912422 to 441220 + set 6 from 441220 to 391421 + get 8 + get 8 + set 0 from 434440 to 387128 + set 5 from 639948 to 690434 + remove 2 + set 7 from 239866 to 381374 + add 7 30087 + remove 4 + add 1 800671 + add 0 506296 + remove 6 + add 6 782888 + remove 6 + set 8 from 381374 to 867927 + remove 1 + get 0 + add 3 738575 + get 1 + add 9 193698 + remove 1 + get 7 + add 5 760971 + remove 4 + remove 9 + set 3 from 116030 to 421319 + add 6 980801 + remove 6 + remove 8 + set 5 from 314295 to 97096 + add 1 912542 + get 3 + add 4 665271 + remove 1 + get 1 + set 7 from 30087 to 173738 + add 2 567815 + set 8 from 173738 to 487532 + add 5 158949 + remove 8 + add 5 101849 + get 10 + get 10 + remove 0 + set 3 from 665271 to 329352 + set 6 from 421319 to 124986 + add 2 85577 + get 1 + set 7 from 124986 to 355950 + get 10 + get 4 + remove 8 + add 1 561636 + add 1 575397 + set 9 from 355950 to 684350 + add 10 727397 + set 11 from 487532 to 976522 + remove 4 + add 0 192842 + get 5 + get 1 + remove 3 + set 4 from 738575 to 352425 + get 9 + remove 6 + get 4 + get 3 + add 2 967097 + add 9 744484 + set 8 from 684350 to 797371 + add 7 978084 + add 12 771716 + set 3 from 575397 to 549325 + set 1 from 896351 to 38483 + get 10 + add 4 669821 + set 6 from 352425 to 414301 + remove 15 + set 1 from 38483 to 635176 + remove 11 + remove 12 + remove 10 + get 5 + add 1 480281 + add 9 817606 + remove 10 + add 9 895006 + set 3 from 967097 to 505837 + add 13 741142 + remove 3 + remove 11 + get 4 + remove 2 + remove 8 + remove 10 + remove 6 + add 2 108115 + set 0 from 192842 to 968703 + set 0 from 968703 to 415895 + set 3 from 549325 to 412788 + remove 8 + add 6 395747 + add 8 650394 + get 4 + remove 6 + get 8 + add 5 672604 + add 4 797425 + remove 3 + remove 9 + get 9 + add 5 791020 + set 1 from 480281 to 44368 + remove 7 + remove 0 + get 2 + remove 2 + set 0 from 44368 to 843196 + add 2 16899 + get 6 + set 5 from 672604 to 389654 + get 7 + add 7 318877 + add 6 667183 + add 7 535276 + set 5 from 389654 to 289157 + add 9 374367 + get 7 + add 11 943376 + set 9 from 374367 to 128504 + get 5 + set 9 from 128504 to 147312 + remove 13 + add 2 832903 + get 11 + remove 8 + get 12 + add 4 99572 + set 5 from 669821 to 632457 + get 9 + remove 12 + set 6 from 791020 to 910063 + remove 6 + remove 8 + set 1 from 108115 to 913701 + get 10 + add 7 574821 + set 3 from 16899 to 220157 + get 7 + get 5 + set 10 from 318877 to 59539 + remove 7 + remove 0 + add 4 548143 + set 0 from 913701 to 609948 + set 3 from 99572 to 916988 + get 6 + get 0 + add 8 40550 + get 1 + get 9 + set 3 from 916988 to 274569 + add 11 954225 + set 3 from 274569 to 823677 + set 5 from 632457 to 657036 + add 3 334404 + set 2 from 220157 to 367564 + set 8 from 667183 to 758580 + get 7 + set 12 from 954225 to 378111 + set 9 from 40550 to 121426 + get 11 + get 11 + set 4 from 823677 to 116407 + set 13 from 650394 to 171406 + set 7 from 289157 to 392105 + add 0 140775 + add 14 502870 + get 8 + set 8 from 392105 to 852512 + add 0 997929 + set 15 from 502870 to 858079 + get 15 + get 5 + remove 11 + remove 15 + get 7 + remove 2 + remove 7 + set 6 from 548143 to 33455 + set 0 from 997929 to 970988 + remove 3 + set 10 from 378111 to 406222 + get 9 + set 5 from 33455 to 13196 + remove 3 + remove 7 + add 8 399596 + remove 7 + set 6 from 758580 to 289055 + add 2 759235 + add 0 461156 + get 2 + get 9 + remove 4 + remove 10 + add 6 718569 + set 3 from 759235 to 547209 + get 8 + set 10 from 406222 to 283307 + set 4 from 116407 to 760622 + add 2 662554 + add 1 405361 + add 11 427921 + add 12 853315 + get 3 + remove 12 + remove 5 + add 4 32481 + remove 7 + set 9 from 289055 to 382683 + remove 6 + remove 2 + add 9 851672 + remove 0 + remove 1 + remove 2 + add 6 537905 + remove 4 + get 7 + set 6 from 851672 to 680751 + remove 7 + get 4 + remove 2 + get 5 + get 3 + get 0 + add 0 49039 + add 0 307491 + set 4 from 852512 to 905717 + add 2 483902 + add 0 335550 + remove 1 + set 3 from 405361 to 847807 + set 0 from 335550 to 961002 + get 8 + add 7 502066 + add 9 794929 + set 7 from 502066 to 263777 + remove 9 + add 0 550254 + add 6 303007 + add 5 883956 + get 10 + add 7 310519 + get 12 + get 8 + set 6 from 32481 to 714326 + set 9 from 905717 to 156745 + add 10 176263 + get 6 + set 13 from 537905 to 571449 + add 9 70695 + get 4 + get 0 + add 15 910646 + set 1 from 961002 to 581606 + get 7 + add 8 770452 + set 15 from 571449 to 853730 + set 17 from 680751 to 413428 + add 4 292703 + add 12 324850 + set 14 from 176263 to 694353 + get 6 + get 19 + get 17 + add 16 894049 + remove 15 + add 20 97267 + get 19 + remove 10 + get 1 + set 17 from 910646 to 931413 + remove 10 + remove 16 + set 8 from 310519 to 401424 + remove 9 + add 11 422931 + set 16 from 413428 to 657063 + add 5 140423 + remove 3 + remove 13 + get 7 + get 11 + add 13 186385 + add 1 507094 + get 7 + get 19 + remove 9 + remove 11 + remove 8 + set 12 from 263777 to 347364 + set 10 from 694353 to 250181 + add 1 510776 + get 10 + remove 4 + set 0 from 550254 to 142143 + get 2 + remove 10 + remove 8 + remove 2 + add 10 971341 + get 9 + remove 14 + remove 4 + get 8 + add 8 859065 + remove 5 + set 2 from 581606 to 940516 + remove 10 + get 0 + set 4 from 847807 to 175503 + add 9 134127 + set 9 from 134127 to 65629 + get 0 + remove 5 + set 0 from 142143 to 27701 + remove 7 + get 7 + remove 10 + get 7 + get 4 + remove 2 + set 4 from 186385 to 521149 + set 8 from 657063 to 207894 + remove 4 + get 4 + set 7 from 207894 to 189143 + remove 0 + remove 1 + get 3 + get 2 + add 3 61973 + set 4 from 65629 to 873403 + set 5 from 971341 to 391229 + remove 3 + set 3 from 873403 to 870298 + get 2 + remove 4 + remove 4 + get 3 + get 2 + remove 3 + add 0 573579 + remove 1 + get 1 + add 2 293756 + set 1 from 175503 to 79870 + add 3 200832 + add 4 242333 + remove 0 + remove 4 + add 3 745079 + set 1 from 293756 to 983661 + set 4 from 242333 to 676031 + remove 4 + add 1 803739 + set 4 from 745079 to 773979 + get 1 + get 2 + remove 0 + add 1 925531 + remove 3 + remove 3 + remove 0 + get 0 + get 0 + add 0 657195 + set 2 from 983661 to 336257 + add 0 506328 + add 3 869967 + set 0 from 506328 to 368241 + add 0 508950 + get 4 + add 5 585978 + get 2 + remove 5 + remove 1 + remove 2 + add 3 535 + add 3 801768 + add 4 856530 + get 6 + get 3 + remove 5 + get 5 + set 1 from 657195 to 651513 + get 2 + add 2 655429 + add 4 130761 + get 2 + remove 2 + get 3 + set 4 from 801768 to 725194 + set 2 from 869967 to 721793 + get 6 + remove 4 + get 2 + get 2 + get 3 + remove 5 + remove 2 + set 2 from 130761 to 348842 + remove 0 + add 0 603519 + add 0 951727 + set 0 from 951727 to 975950 + add 3 923659 + set 5 from 856530 to 691722 + add 1 838899 + get 5 + set 4 from 923659 to 404990 + set 4 from 404990 to 859388 + add 3 62328 + get 2 + remove 4 + set 4 from 859388 to 459448 + remove 3 + remove 1 + remove 4 + add 3 405442 + add 3 326905 + add 1 829230 + get 1 + get 5 + remove 3 + get 0 + remove 3 + remove 4 + set 3 from 405442 to 167698 + remove 2 + add 2 287001 + remove 0 + remove 1 + set 1 from 167698 to 815110 + add 0 295920 + add 2 836790 + get 3 + set 1 from 829230 to 200642 + get 1 + add 2 915960 + add 1 366827 + get 5 + remove 2 + add 2 53973 + remove 2 + remove 1 + add 2 844194 + add 1 874791 + add 0 363876 + add 0 23019 + add 0 863442 + get 8 + add 7 648484 + get 5 + add 5 966491 + set 0 from 863442 to 712913 + set 9 from 836790 to 385240 + set 5 from 966491 to 471085 + set 2 from 363876 to 368646 + remove 10 + remove 7 + set 2 from 368646 to 435824 + set 7 from 648484 to 42991 + get 1 + remove 8 + get 2 + get 0 + get 7 + add 5 673180 + add 7 584482 + add 2 773584 + add 10 453299 + remove 4 + remove 0 + get 5 + get 5 + remove 1 + get 0 + set 6 from 915960 to 746986 + get 0 + get 0 + get 7 + add 2 575614 + remove 5 + get 2 + remove 0 + set 6 from 453299 to 800184 + add 6 818389 + remove 0 + remove 0 + get 4 + get 6 + get 0 + add 3 894757 + add 1 423319 + get 4 + set 4 from 894757 to 960416 + remove 2 + set 3 from 960416 to 396574 + remove 5 + add 1 495128 + add 2 262893 + add 5 496753 + get 1 + get 5 + add 7 635484 + remove 7 + get 1 + set 1 from 495128 to 125680 + set 9 from 42991 to 454394 + add 2 619078 + add 8 659711 + set 1 from 125680 to 656895 + add 6 73024 + remove 6 + set 6 from 496753 to 78591 + get 3 + set 8 from 659711 to 883309 + add 1 842356 + get 4 + remove 2 + remove 3 + set 8 from 746986 to 413551 + get 9 + get 4 + set 0 from 874791 to 492854 + add 6 989771 + set 3 from 423319 to 817204 + add 9 226502 + remove 12 + set 2 from 619078 to 755431 + add 0 11620 + set 1 from 492854 to 245432 + remove 5 + get 9 + add 8 364456 + add 2 919085 + add 0 887710 + remove 13 + remove 11 + get 12 + get 10 + add 8 191778 + add 2 720452 + remove 2 + get 0 + set 6 from 817204 to 182212 + get 6 + remove 1 + add 5 180284 + get 9 + add 5 114015 + remove 10 + set 10 from 396574 to 70820 + remove 5 + set 6 from 182212 to 306517 + set 9 from 70820 to 74635 + remove 7 + get 9 + add 7 115572 + remove 6 + add 8 307423 + set 6 from 115572 to 313341 + get 5 + add 4 73212 + get 13 + set 6 from 180284 to 862808 + set 1 from 245432 to 213117 + remove 0 + get 12 + add 7 228693 + add 8 979448 + remove 12 + remove 9 + get 2 + add 0 648199 + add 5 726294 + add 3 524237 + get 9 + add 11 789963 + get 6 + remove 12 + add 1 73362 + remove 3 + set 13 from 74635 to 9357 + get 1 + remove 12 + get 0 + get 6 + set 4 from 842356 to 181853 + remove 14 + set 4 from 181853 to 325980 + add 1 423256 + remove 10 + get 9 + add 10 170993 + add 1 589036 + remove 4 + remove 3 + remove 2 + add 3 995117 + get 1 + set 7 from 755431 to 162827 + add 1 713937 + get 5 + set 7 from 726294 to 395881 + get 0 + get 9 + remove 12 + set 6 from 73212 to 493510 + get 0 + remove 8 + set 8 from 862808 to 229301 + add 1 945850 + get 8 + get 3 + add 6 209834 + remove 0 + get 8 + add 1 511737 + get 6 + set 1 from 511737 to 67106 + get 1 + set 0 from 945850 to 304225 + get 10 + add 9 76209 + add 3 447103 + set 4 from 589036 to 557276 + set 3 from 447103 to 397005 + set 0 from 304225 to 761627 + add 0 432867 + remove 0 + set 7 from 209834 to 348840 + get 10 + remove 9 + get 5 + set 7 from 348840 to 604082 + get 2 + set 13 from 228693 to 363845 + set 12 from 170993 to 876063 + add 3 278466 + set 6 from 524237 to 405908 + add 3 730442 + get 12 + remove 13 + remove 0 + remove 10 + add 9 391794 + remove 6 + set 11 from 876063 to 273353 + get 11 + add 9 309813 + set 7 from 604082 to 166890 + set 8 from 391794 to 108526 + add 2 555852 + get 1 + remove 16 + remove 1 + add 0 881282 + get 14 + remove 9 + add 5 908900 + get 1 + get 0 + remove 6 + remove 9 + set 7 from 995117 to 221143 + get 9 + get 3 + add 11 781303 + add 8 84585 + remove 3 + set 3 from 278466 to 943123 + add 13 203562 + remove 12 + get 8 + remove 3 + remove 13 + add 3 894330 + set 10 from 395881 to 64530 + add 9 435034 + remove 12 + add 0 841779 + add 11 381896 + add 5 212485 + set 9 from 84585 to 268496 + remove 12 + add 3 912780 + set 3 from 912780 to 938368 + remove 13 + get 9 + set 13 from 64530 to 71484 + get 0 + set 12 from 435034 to 786513 + get 14 + remove 8 + set 8 from 221143 to 460021 + get 11 + set 10 from 166890 to 699835 + set 10 from 699835 to 372072 + remove 3 + set 13 from 363845 to 76001 + remove 3 + remove 1 + remove 3 + get 9 + add 3 665656 + set 9 from 71484 to 392580 + add 11 314844 + remove 10 + add 9 269498 + get 9 + get 10 + remove 10 + set 9 from 269498 to 100372 + get 3 + get 4 + set 9 from 100372 to 630176 + get 10 + set 3 from 665656 to 981283 + set 2 from 894330 to 609264 + remove 3 + set 9 from 314844 to 219922 + add 1 249031 +LinkedList @ 1000 ops: 0.165524s +==10897== Mismatched free() / delete / delete [] +==10897== at 0x4C3123B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) +==10897== by 0x402FFF: ods::SimpList::~SimpList() (simplist.h:42) +==10897== by 0x4024BD: main (list_bench.cc:135) +==10897== Address 0x5b21f90 is 0 bytes inside a block of size 64 alloc'd +==10897== at 0x4C3089F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) +==10897== by 0x4068C3: ods::SimpList::grow() (simplist.h:140) +==10897== by 0x406693: ods::SimpList::add(unsigned long, int) (simplist.h:94) +==10897== by 0x40297F: benchmark(ods::List&, int) (list_bench.cc:81) +==10897== by 0x4025F7: run(std::__cxx11::basic_string, std::allocator >, ods::List&, int) (list_bench.cc:108) +==10897== by 0x402395: main (list_bench.cc:128) +==10897== +--10897-- REDIR: 0x57be390 (libc.so.6:free) redirected to 0x4c30cd0 (free) +==10897== +==10897== HEAP SUMMARY: +==10897== in use at exit: 0 bytes in 0 blocks +==10897== total heap usage: 273 allocs, 273 frees, 81,780 bytes allocated +==10897== +==10897== All heap blocks were freed -- no leaks are possible +==10897== +==10897== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0) +==10897== +==10897== 1 errors in context 1 of 2: +==10897== Mismatched free() / delete / delete [] +==10897== at 0x4C3123B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) +==10897== by 0x402FFF: ods::SimpList::~SimpList() (simplist.h:42) +==10897== by 0x4024BD: main (list_bench.cc:135) +==10897== Address 0x5b21f90 is 0 bytes inside a block of size 64 alloc'd +==10897== at 0x4C3089F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) +==10897== by 0x4068C3: ods::SimpList::grow() (simplist.h:140) +==10897== by 0x406693: ods::SimpList::add(unsigned long, int) (simplist.h:94) +==10897== by 0x40297F: benchmark(ods::List&, int) (list_bench.cc:81) +==10897== by 0x4025F7: run(std::__cxx11::basic_string, std::allocator >, ods::List&, int) (list_bench.cc:108) +==10897== by 0x402395: main (list_bench.cc:128) +==10897== +==10897== +==10897== 1 errors in context 2 of 2: +==10897== Mismatched free() / delete / delete [] +==10897== at 0x4C3123B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) +==10897== by 0x40692E: ods::SimpList::grow() (simplist.h:146) +==10897== by 0x406693: ods::SimpList::add(unsigned long, int) (simplist.h:94) +==10897== by 0x40297F: benchmark(ods::List&, int) (list_bench.cc:81) +==10897== by 0x4025F7: run(std::__cxx11::basic_string, std::allocator >, ods::List&, int) (list_bench.cc:108) +==10897== by 0x402395: main (list_bench.cc:128) +==10897== Address 0x5b20ef0 is 0 bytes inside a block of size 32 alloc'd +==10897== at 0x4C3089F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) +==10897== by 0x402DE3: ods::SimpList::SimpList() (simplist.h:34) +==10897== by 0x402350: main (list_bench.cc:127) +==10897== +==10897== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0) diff --git a/ods/notes/chapter1.txt b/ods/notes/chapter1.txt new file mode 100644 index 0000000..55f86d3 --- /dev/null +++ b/ods/notes/chapter1.txt @@ -0,0 +1,171 @@ +# Chapter 1 + +## Efficiency + +Concerns: +1. Number of operations +2. Processor speeds +3. Storage space + +## Interfaces + +* Interface / abstract data type + +### Queue interface + +* `add(x)` (aka `queue`): add `x` to the queue +* `remove()` (aka `dequeue`): remove the next value from queue and return it + +* Normal queue: the first element inserted is removed first +* Priority queue: elements are inserted with a priority, and the smallest + element is removed. This function is usually called `deleteMin`. +* LIFO queue: a stack; add and remove are called `push` and `pop`. +* Deque: generalisation of these + * `addFirst(x)` + * `removeFirst(x)` + * `addLast(x)` + * `removeLast(x)` +* Stack: addFirst, removeFirst +* Queue: addLast, removeFirst + +### List interface + +The List interface subsumes the Queue interface. A list is just a sequence of +values, and a Queue becomes a special case of it. + +Interface: + +* size() +* get(i): get i'th element +* set(i, x): set the i'th element to x +* add(i, x): insert x at position i +* remove(i): remove the i'th element + +### USet (unordered sets) + +USets are a collection of unique items in no particular order; this mimics a +mathematical set. + +Interface: + +* `size()`: returns the number of elements in the set +* `add(x)`: add x to the set if it doesn't already exist +* `remove(x)`: remove x from the set if it doesn't already exist +* `find(y)`: membership test + +Note that y and x may be distinct objects, and only need to satisfy an +equality test. For example, a dictionary or hashmap is created using a tuple +`(key, value)`; `find` compares on `key` and two objects are considered equal +if their keys match. + +### SSet (sorted set) + +A USet where order matters. Its interface only changes in the `find` function: + +* `find(x)`: find the smallest y s.t. y >= x. thereby returning a useful value + even if x isn't in the set. AKA successor search. + +Difference between USet and SSet: sorting requires more steps (run time) and +complexity. A USet should be used unless an SSet is explicitly required. + +## Mathematical background + +(See notebook). + +## The model of computation + +Proper analysis requires a mathematical model of computation. The model in the +book is on a w-bit word-RAM model. + +* we can access cells of memory, each of which stores a w-bit word +* basic operations (arithmetic and logical) take constant time +* cells can be read or written in constant time +* the memory manager allows allocating a block of k cells of memory in O(k) + time +* size constraint: w >= log(n) where n is the number of elements stored in a + data structure +* data structures use a generic type T such that T occupies one word + +## Correctness, time complexity, and space complexity + +Three factors for analysing a data structure: + +* correctness: data structure must implement the interface +* time complexity: run times of operations on the data structure should + be as small as possible +* space complexity: the storage space used by a data structure should be + as small as possible + +Run times come in three flavours: + +1. Worst-case: an operation never takes longer than this +2. Amortized: if a data structure has an amortized run time of f(n), then + a sequence of m operations takes at most m f(n) time. +3. Expected: the actual run time is a random variable, and the expected + value of this run time is at most f(n). + +## Exercises + +1. See src/ch01ex01.cc --- note that the last three exercises were skipped for + time. + +2. A Dyck word is a sequence of +1’s and -1’s with the property that the + sum of any prefix of the sequence is never negative. For example, + +1,−1,+1,−1 is a Dyck word, but +1,−1,−1,+1 is not a Dyck word since the + prefix +1 − 1 − 1 < 0. Describe any relationship between Dyck words and + Stack push(x) and pop() operations. + + A +1 corresponds to a push, and a -1 corresponds to a pop. At any point, + the stack must not overflow. + +3. A matched string is a sequence of {, }, (, ), [, and ] characters that are + properly matched. For example, “{{()[]}}” is a matched string, but this + “{{()]}” is not, since the second { is matched with a ]. Show how to use a + stack so that, given a string of length n, you can determine if it is a + matched string in O(n) time. + + The program should push each opening character onto a stack. When a closing + character is encountered, the top of the stack should be the matching + opening character. See src/ch01ex03.cc. + +4. Suppose you have a Stack, s, that supports only the push(x) + and pop() operations. Show how, using only a FIFO Queue, q, you can + reverse the order of all elements in s. + + See src/ch01ex04.cc: you just pop each element from the stack → queue, + then pop the elements off the queue. If you wanted to reverse the stack + itself, you'd just push the elements back onto the stack. + +5. Using a USet, implement a Bag. A Bag is like a USet—it supports the add(x), + remove(x) and find(x) methods—but it allows duplicate elements to be + stored. The find(x) operation in a Bag returns some element (if any) that + is equal to x. In addition, a Bag supports the findAll(x) operation that + returns a list of all elements in the Bag that are equal to x. + + In progress: src/ch01ex05.cc. + +6. From scratch, write and test implementations of the List, USet and SSet + interfaces. These do not have to be efficient. They can be used later to + test the correctness and performance of more efficient implementations. + + In progress: src/ch01ex06.cc, src/ods/simplist.h, src/ods/uset.h. + +7. Work to improve the performance of your implementations + from the previous question using any tricks you can think of. Experiment + and think about how you could improve the performance of add(i,x) and + remove(i) in your List implementation. Think about how you could improve + the performance of the find(x) operation in your USet and SSet + implementations. This exercise is designed to give you a feel for how + difficult it can be to obtain efficient implementations of these interfaces + + Some initial ideas: + 1. A linked list could improve add --- instead of having to move elements + in place, you would just insert in between. For a forward-iterating + insertion (e.g. for j := 0; j < i; j++), there are decreasing benefits + as you insert elements farther in the list. A potential improvement + might be a doubly-linked list with the iteration direction determined by + distance from the centre, though this comes at the cost of additional + complexity. The same improvements would apply to remove. + 2. For the sorted list, a basic improvement for find would be to pick the + middle of the list and do an equality check, basically bisecting to + find where the value *would* be. \ No newline at end of file diff --git a/ods/perf.data b/ods/perf.data new file mode 100644 index 0000000..e108f10 Binary files /dev/null and b/ods/perf.data differ diff --git a/ods/perf.txt b/ods/perf.txt new file mode 100644 index 0000000..71a81a3 --- /dev/null +++ b/ods/perf.txt @@ -0,0 +1,46 @@ +Samples: 13K of event 'cycles', Event count (approx.): 15926976992 +Overhead Command Shared Object Symbol + 31.66% list_bench list_bench [.] ods::LinkedList::get + 8.29% list_bench list_bench [.] ods::LinkedList::remove + 7.99% list_bench list_bench [.] ods::LinkedList::set + 7.92% list_bench list_bench [.] ods::LinkedList::add + 4.55% list_bench list_bench [.] ods::SimpList::add + 4.12% list_bench list_bench [.] ods::SimpList::remove + 3.45% list_bench list_bench [.] std::uniform_int_distribution::operator()::operator() > + 1.27% list_bench libstdc++.so.6.0.24 [.] std::ostream::sentry::~sentry + 1.15% list_bench [kernel.kallsyms] [k] common_file_perm + 1.09% list_bench list_bench [.] std::mersenne_twister_engine > >::_M_insert_int + 0.43% list_bench libc-2.26.so [.] _IO_fflush + 0.41% list_bench libstdc++.so.6.0.24 [.] std::ostream::_M_insert + 0.41% list_bench libstdc++.so.6.0.24 [.] std::num_put > >::_M_insert_int + 0.40% list_bench libstdc++.so.6.0.24 [.] 0x0000000000107209 + 0.40% list_bench [kernel.kallsyms] [k] vfs_write + 0.36% list_bench list_bench [.] __gnu_cxx::__normal_iterator > >::__normal_iterator + 0.34% list_bench libc-2.26.so [.] __GI___strlen_sse2 + 0.32% list_bench libstdc++.so.6.0.24 [.] std::ostream::put + 0.30% list_bench [kernel.kallsyms] [k] entry_SYSCALL_64_fastpath + 0.29% list_bench libstdc++.so.6.0.24 [.] std::endl > + 0.29% list_bench libc-2.26.so [.] _IO_file_write@@GLIBC_2.2.5 + 0.27% list_bench [kernel.kallsyms] [k] rw_verify_area + 0.25% list_bench list_bench [.] std::uniform_int_distribution::param_type::a + 0.24% list_bench [kernel.kallsyms] [k] fsnotify + 0.23% list_bench [kernel.kallsyms] [k] __irqentry_text_start + 0.22% list_bench libstdc++.so.6.0.24 [.] std::operator<< > + 0.21% list_bench libstdc++.so.6.0.24 [.] __gnu_cxx::stdio_sync_filebuf >::xsputn + 0.21% list_bench list_bench [.] __gnu_cxx::__normal_iterator > >::operator+ + 0.21% list_bench list_bench [.] ods::SimpList::size \ No newline at end of file diff --git a/ods/src/Makefile.am b/ods/src/Makefile.am new file mode 100644 index 0000000..b1f2881 --- /dev/null +++ b/ods/src/Makefile.am @@ -0,0 +1,27 @@ +AM_CPPFLAGS = -Wall -Wextra -pedantic -Wshadow -Wpointer-arith -Wcast-align +AM_CPPFLAGS += -Wwrite-strings -Wmissing-declarations -Wno-long-long -Werror +AM_CPPFLAGS += -Wunused-variable -std=c++17 -D_XOPEN_SOURCE -O0 -g -I. +AM_CPPFLAGS += -fno-elide-constructors -Weffc++ -fPIC + +bin_PROGRAMS := ch01ex01 ch01ex03 ch01ex04 ch01ex05 ch01ex06 \ + list_bench uset_bench sset_bench +ch01ex01_SOURCES := ch01ex01.cc +ch01ex03_SOURCES := ch01ex03.cc +ch01ex04_SOURCES := ch01ex04.cc +ch01ex05_SOURCES := ch01ex05.cc +ch01ex06_SOURCES := ch01ex06.cc +list_bench_SOURCES := list_bench.cc +uset_bench_SOURCES := uset_bench.cc +sset_bench_SOURCES := sset_bench.cc + +BENCH_OPS ?= 1000000 + +benchmarks: list_bench uset_bench sset_bench + @echo "LIST BENCHMARKS" + @./list_bench $(BENCH_OPS) > /dev/null + @echo + @echo "USET BENCHMARKS" + @./uset_bench $(BENCH_OPS) > /dev/null + @echo + @echo "SSET BENCHMARKS" + @./sset_bench $(BENCH_OPS) > /dev/null \ No newline at end of file diff --git a/ods/src/ch01ex01.cc b/ods/src/ch01ex01.cc new file mode 100644 index 0000000..f2afc63 --- /dev/null +++ b/ods/src/ch01ex01.cc @@ -0,0 +1,234 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +// Solve the following problems by reading a text file one line at a time +// and performing operations on each line in the appropriate data structure(s). +// Your implementations should be fast enough that even files containing +// a million lines can be processed in a few seconds. + + +// Read the input one line at a time and then write the lines out in +// reverse order, so that the last input line is printed first, then the +// second last input line, and so on. +static void +problem1(const char *path) +{ + ifstream ifs(path); + string line; + stack s; + + if (!ifs) { + return; + } + + while (getline(ifs, line)) { + s.push(line); + } + + while (!s.empty()) { + cout << s.top() << endl; + s.pop(); + } + + ifs.close(); + return; +} + + +// Read the first 50 lines of input and then write them out in reverse +// order. Read the next 50 lines and then write them out in reverse +// order. Do this until there are no more lines left to read, at which +// point any remaining lines should be output in reverse order. +// +// In other words, your output will start with the 50th line, then the +// 49th, then the 48th, and so on down to the first line. This will be +// followed by the 100th line, followed by the 99th, and so on down to +// the 51st line. And so on. +// +// Your code should never have to store more than 50 lines at any given +// time. +static void +problem2(const char *path) +{ + ifstream ifs(path); + string line; + stack s; + bool stop = false; + + if (!ifs) { + return; + } + + while (!stop) { + while (s.size() < 50) { + if (getline(ifs, line)) { + s.push(line); + } else { + stop = true; + break; + } + } + + while (!s.empty()) { + cout << s.top() << endl; + s.pop(); + } + } +} + + +// Read the input one line at a time. At any point after reading the +// first 42 lines, if some line is blank (i.e., a string of length 0), then +// output the line that occured 42 lines prior to that one. For example, +// if Line 242 is blank, then your program should output line 200. +// This program should be implemented so that it never stores more +// than 43 lines of the input at any given time. +static void +problem3(const char *path) +{ + ifstream ifs(path); + string line; + deque q; + + if (!ifs) { + return; + } + + while (getline(ifs, line)) { + if (q.size() > 42) { + q.pop_back(); + } + q.push_front(line); + + if (line == "") { + cout << q.back() << endl; + } + } +} + +// Read the input one line at a time and write each line to the output +// if it is not a duplicate of some previous input line. Take special care +// so that a file with a lot of duplicate lines does not use more memory +// than what is required for the number of unique lines. +static void +problem4(const char *path) +{ + ifstream ifs(path); + string line; + set set; + + if (!ifs) { + return; + } + + while (getline(ifs, line)) { + if (set.count(line) == 0) { + cout << line << endl; + set.insert(line); + } + } +} + + +// Read the input one line at a time and write each line to the output +// only if you have already read this line before. (The end result is that +// you remove the first occurrence of each line.) Take special care so +// that a file with a lot of duplicate lines does not use more memory +// than what is required for the number of unique lines. +static void +problem5(const char *path) +{ + ifstream ifs(path); + string line; + set set; + + if (!ifs) { + return; + } + + while (getline(ifs, line)) { + if (set.count(line) == 1) { + cout << line << endl; + } else { + set.insert(line); + } + } +} + +// main should just execute the problems in sequence. +int +main(int argc, char *argv[]) +{ + int problem = -1; + + if (argc < 2) { + cerr << "No input file specified, exiting." << endl; + exit(1); + } + + if (argc == 3) { + problem = stoi(string(argv[2])); + } + + if (problem > 0) { + switch (problem) { + case 1: + cout << "*** PROBLEM 1 ***" << endl; + problem1(argv[1]); + cout << endl << endl; + break; + case 2: + cout << "*** PROBLEM 2 ***" << endl; + problem2(argv[1]); + cout << endl << endl; + break; + case 3: + cout << "*** PROBLEM 3 ***" << endl; + problem3(argv[1]); + cout << endl << endl; + break; + case 4: + cout << "*** PROBLEM 4 ***" << endl; + problem4(argv[1]); + cout << endl << endl; + break; + case 5: + cout << "*** PROBLEM 5 ***" << endl; + problem5(argv[1]); + cout << endl << endl; + break; + default: + cerr << "Unknown problem " << problem << endl; + exit(1); + } + exit(0); + } + + cout << "*** PROBLEM 1 ***" << endl; + problem1(argv[1]); + cout << endl << endl; + + cout << "*** PROBLEM 2 ***" << endl; + problem2(argv[1]); + cout << endl << endl; + + cout << "*** PROBLEM 3 ***" << endl; + problem3(argv[1]); + cout << endl << endl; + + cout << "*** PROBLEM 4 ***" << endl; + problem4(argv[1]); + cout << endl << endl; + + cout << "*** PROBLEM 5 ***" << endl; + problem5(argv[1]); + cout << endl << endl; +} \ No newline at end of file diff --git a/ods/src/ch01ex03.cc b/ods/src/ch01ex03.cc new file mode 100644 index 0000000..4a998af --- /dev/null +++ b/ods/src/ch01ex03.cc @@ -0,0 +1,67 @@ +#include +#include +#include +using namespace std; + +int +main(int argc, char *argv[]) +{ + stack s; + + for (int i = 1; i < argc; i++) { + string ms(argv[i]); + bool matched = true; + + for (auto c : ms) { + switch (c) { + case '{': + case '(': + case '[': + s.push(c); + break; + case '}': + if (s.top() != '{') { + cerr << "Saw '" << s.top() << "' but expected '{'." << endl; + matched = false; + } + else { + s.pop(); + } + break; + case ']': + if (s.top() != '[') { + cerr << "Saw '" << s.top() << "' but expected '['." << endl; + matched = false; + } + else { + s.pop(); + } + break; + case ')': + if (s.top() != '(') { + cerr << "Saw '" << s.top() << "' but expected '('." << endl; + matched = false; + } + else { + s.pop(); + } + break; + default: + cerr << "Invalid character in string: " << c << endl; + matched = false; + } + + if (!matched) { + break; + } + + } + + if (!matched) { + cerr << "'" << ms << "' is not a matched string." << endl; + } + else { + cout << "'" << ms << "' is a matched string." << endl; + } + } +} \ No newline at end of file diff --git a/ods/src/ch01ex04.cc b/ods/src/ch01ex04.cc new file mode 100644 index 0000000..8015c53 --- /dev/null +++ b/ods/src/ch01ex04.cc @@ -0,0 +1,43 @@ +#include +#include +#include +#include +using namespace std; + + + +static void +print_queue(queue& q) +{ + while (!q.empty()) { + cout << q.front() << " "; + q.pop(); + } + cout << endl; +} + + +int +main(int argc, char *argv[]) +{ + stack s; + queue q; + + for (int i = 1; i < argc; i++) { + string line(argv[i]); + int arg = stoi(line); + + s.push(arg); + } + + while (!s.empty()) { + // NB: the pop() interface in the book returns the topmost + // element while removing it; the C++ STL interface does + // not, requiring the separate top() and pop() invocations. + int arg = s.top(); + s.pop(); + q.push(arg); + } + + print_queue(q); +} diff --git a/ods/src/ch01ex05.cc b/ods/src/ch01ex05.cc new file mode 100644 index 0000000..ebe585a --- /dev/null +++ b/ods/src/ch01ex05.cc @@ -0,0 +1,22 @@ +#include +#include + +// Using a USet, implement a Bag. A Bag is like a USet — it supports the add(x), +// remove(x), and find (x) methods — but it allows duplicate elements to be +// stored. The find(x) operation in a Bag returns some element (if any) that is +// equal to x. In addition, a Bag supports the findAll(x) operation that returns +// a list of all elements in the Bag that are equal to x. + +// template +// class Bag { +// public: +// +// private: +// vector v; +// }; + +int +main(void) +{ + return 0; +} diff --git a/ods/src/ch01ex06.cc b/ods/src/ch01ex06.cc new file mode 100644 index 0000000..fce753a --- /dev/null +++ b/ods/src/ch01ex06.cc @@ -0,0 +1,147 @@ +#include +#include +#include +#include +#include +#include +using namespace std; + + +static void +check_simplist(void) +{ + ods::SimpList sl; + + sl.add(0, 1); + sl.add(1, 2); + sl.add(2, 3); + assert(sl.size() == 3); + + sl.add(0, 4); + sl.add(1, 5); + sl.add(2, 6); + assert(sl.size() == 6); + + int expected[6] = {4, 5, 6, 1, 2, 3}; + for (size_t i = 0; i < 6; i++) { + assert(sl.get(i) == expected[i]); + } + + bool caught = false; + try { + sl.add(8, 8); + } catch (std::invalid_argument) { + caught = true; + } + assert(caught); + + assert(sl.get(2) == 6); + sl.remove(2); + assert(sl.get(2) == 1); + assert(sl.size() == 5); + sl.set(2, 6); + assert(sl.get(2) == 6); + + // expected = {1, 2, 3, 4, 5, 6}; + for (size_t i = 0; i < 6; i++) { + expected[i] = i+1; + } + + for (size_t i = 0; i < 5; i++) { + sl.set(i, i+1); + } + sl.add(5, 6); + + for (size_t i = 0; i < 6; i++) { + assert(sl.get(i) == expected[i]); + } +} + + +static void +check_simpuset(void) +{ + ods::SimpUSet us; + + assert(us.add(1)); + assert(us.size() == 1); + assert(us.find(1)); + assert(!us.add(1)); + assert(us.size() == 1); + assert(us.add(2)); + assert(us.find(2)); + assert(us.add(3)); + assert(us.size() == 3); + assert(us.find(3)); + + auto removed = us.remove(2); + assert(removed == 2); + assert(us.size() == 2); + assert(!us.find(2)); +} + + +static void +check_simpsset(void) +{ + ods::SimpSSet ss; + + assert(ss.add(2)); + assert(ss.size() == 1); + assert(ss.find(2)); + assert(!ss.add(2)); + assert(ss.size() == 1); + assert(ss.add(1)); + assert(ss.find(1)); + assert(ss.size() == 2); + assert(ss.add(3)); + assert(ss.size() == 3); + assert(ss.find(3)); + + auto removed = ss.remove(2); + assert(removed == 2); + assert(ss.size() == 2); + assert(!ss.find(2)); +} + +void check_linkedlist(void); + +void +check_linkedlist() +{ + ods::LinkedList ll; + + ll.add(0, 1); + assert(ll.size() == 1); + assert(ll.get(0) == 1); + ll.add(0, 2); + assert(ll.size() == 2); + assert(ll.get(0) == 2); + ll.add(2, 4); + assert(ll.get(2) == 4); + assert(ll.size() == 3); + + ll.set(1, 5); + assert(ll.get(1) == 5); + + ll.remove(1); + assert(ll.size() == 2); + assert(ll.get(1) == 4); + ll.remove(1); + assert(ll.size() == 1); + ll.remove(0); + assert(ll.size() == 0); + + ll.add(0, 1); +} + + +int +main(void) +{ + check_simplist(); + check_simpuset(); + check_simpsset(); + check_linkedlist(); + cout << "OK" << endl; +} diff --git a/ods/src/list_bench.cc b/ods/src/list_bench.cc new file mode 100644 index 0000000..9ff8eb9 --- /dev/null +++ b/ods/src/list_bench.cc @@ -0,0 +1,135 @@ +// list_bench runs benchmarks against List implementations. +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +static mt19937 rng; +static random_device devrand; + +// reseed picks a new seed for the RNG using the system random device. +static void +reseed() +{ + rng.seed(devrand()); +} + + +static int +randint(int low, int high) +{ + uniform_int_distribution dist(low, high); + return dist(rng); +} + +static int +randsizet(size_t low, size_t high) +{ + uniform_int_distribution dist(low, high); + return dist(rng); +} + +static void +benchmark(ods::List& list, int ops) +{ + for (int i = 0; i < ops; i++) { + auto op = randint(0, 3); + size_t j = 0; + int newval, oldval; + + if (list.size() > 0) { + j = randsizet(0, list.size()-1); + } + switch (op) { + // get + case 0: + if (list.size() == 0) { + i--; + continue; + } + + cout << "\tget " << j << endl; + assert(list.get(j) != -1); + break; + // set + case 1: + if (list.size() == 0) { + i--; + continue; + } + + oldval = list.get(j); + newval = oldval; + while (newval == oldval) { + newval = randint(1, 1000000); + } + + cout << "\tset " << j << " from " << oldval << " to " << newval << endl; + assert(list.set(j, newval) == oldval); + assert(list.get(j) == newval); + break; + // add + case 2: + newval = randint(1, 1000000); + list.add(j, newval); + cout << "\tadd " << j << " " << newval << endl; + assert(list.get(j) == newval); + break; + // remove + case 3: + if (list.size() == 0) { + i--; + continue; + } + + auto old_size = list.size(); + cout << "\tremove " << j << endl; + list.remove(j); + assert(list.size() == (old_size-1)); + break; + } + } +} + + +static void +run(string label, ods::List& list, int ops) +{ + std::chrono::steady_clock clock; + + auto start = clock.now(); + benchmark(list, ops); + auto stop = clock.now(); + + std::chrono::duration delta = stop - start; + cerr << label << " @ " << ops << " ops: " << delta.count() << "s" << endl; +} + + +int +main(int argc, char *argv[]) +{ + int ops = 1000; + + if (argc == 2) { + ops = stoi(argv[1]); + } + + reseed(); + + ods::SimpList sl; + run("SimpList", sl, ops); + + ods::VList vl; + run("VList", vl, ops); + + ods::LinkedList ll; + run("LinkedList", ll, ops); +} \ No newline at end of file diff --git a/ods/src/ods/linked_list.h b/ods/src/ods/linked_list.h new file mode 100644 index 0000000..d4c1878 --- /dev/null +++ b/ods/src/ods/linked_list.h @@ -0,0 +1,151 @@ +#ifndef __ODS_ODS_LINKED_LIST__ +#define __ODS_ODS_LINKED_LIST__ + + +#include +#include +#include + + +namespace ods { + +template +struct Node { + struct Node *next; + T value; +}; + +template +class LinkedList : public List { +public: + LinkedList(); + ~LinkedList(); + std::size_t size(void); + T get(std::size_t); + T set(std::size_t, T); + void add(std::size_t, T); + T remove(std::size_t); +private: + struct Node *head; + std::size_t len; +}; + + +template +LinkedList::LinkedList() : head(nullptr), len(0) {} + +template +LinkedList::~LinkedList() +{ + struct Node *cursor = this->head; + while (cursor != nullptr) { + if (this->head != nullptr) { + cursor = this->head->next; + } + delete this->head; + this->head = cursor; + } +} + + +template +std::size_t +LinkedList::size() +{ + return this->len; +} + + +template +void +LinkedList::add(std::size_t i, T value) +{ + assert(i <= this->size()); + struct Node *node = new struct Node; + node->value = value; + node->next = nullptr; + + auto cursor = this->head; + if (i == 0) { + node->next = this->head; + this->head = node; + } + else { + for (size_t j = 0; j < (i-1); j++) { + cursor = cursor->next; + } + + if (cursor != nullptr) { + node->next = cursor->next; + cursor->next = node; + } + else { + this->head = node; + } + } + + this->len++; +} + + +template +T +LinkedList::get(std::size_t i) +{ + assert(i < this->size()); + if (i == 0) { + return this->head->value; + } + + auto cursor = this->head; + for (size_t j = 0; j < i; j++) { + cursor = cursor->next; + } + + return cursor->value; +} + +template +T +LinkedList::set(std::size_t i, T value) +{ + auto cursor = this->head; + for (std::size_t j = 0; j < i; j++) { + cursor = cursor->next; + } + + T prev = cursor->value; + cursor->value = value; + return prev; +} + +template +T +LinkedList::remove(std::size_t i) +{ + if (i == 0) { + auto old = this->head->value; + auto target = this->head; + this->head = this->head->next; + delete target; + this->len--; + return old; + } + + auto cursor = this->head; + for (std::size_t j = 0; j < (i-1); j++) { + cursor = cursor->next; + } + + auto target = cursor->next; + cursor->next = target->next; + auto old = target->value; + delete target; + this->len--; + return old; +} + +} // namespace ods + + +#endif // __ODS_ODS_LINKED_LIST__ \ No newline at end of file diff --git a/ods/src/ods/list.h b/ods/src/ods/list.h new file mode 100644 index 0000000..6fc6781 --- /dev/null +++ b/ods/src/ods/list.h @@ -0,0 +1,22 @@ +#ifndef __ODS_ODS_LIST__ +#define __ODS_ODS_LIST__ + +#include + +namespace ods { + +// Lists are sequences of values. +template +class List { +public: + virtual ~List(void) {}; + virtual std::size_t size(void) =0; + virtual T get(std::size_t) =0; + virtual T set(std::size_t, T) =0; + virtual void add(std::size_t, T) =0; + virtual T remove(std::size_t) =0; +}; + +} // end namespace ods + +#endif diff --git a/ods/src/ods/queue.h b/ods/src/ods/queue.h new file mode 100644 index 0000000..6080d3f --- /dev/null +++ b/ods/src/ods/queue.h @@ -0,0 +1,16 @@ +#ifndef __ODS_QUEUE__ +#define __ODS_QUEUE__ + + +// Dequeue represents a collection of elements to which we can add elements +// and remove the next element. +template +class Dequeue { +public: + virtual void add_first(T); + virtual void add_last(T); + virtual T remove_first(void); + virtual T remove_last(void); + virtual bool empty(void); +}; +#endif \ No newline at end of file diff --git a/ods/src/ods/simplist.h b/ods/src/ods/simplist.h new file mode 100644 index 0000000..9b8fb37 --- /dev/null +++ b/ods/src/ods/simplist.h @@ -0,0 +1,153 @@ +#ifndef __ODS_ODS_SIMPLIST__ +#define __ODS_ODS_SIMPLIST__ + +#include +#include +#include +#include + +namespace ods { + +template +class SimpList : public List { +public: + SimpList(); + ~SimpList(void); + std::size_t size(void); + T get(std::size_t); + T set(std::size_t, T); + void add(std::size_t, T); + T remove(std::size_t); +private: + T *arr; + std::size_t cap; + std::size_t len; + void grow(); + void shrink(); + + const std::size_t DEFAULT_SIZE = 8; +}; + +template +SimpList::SimpList() +{ + arr = new T[DEFAULT_SIZE]; + cap = DEFAULT_SIZE; + len = 0; +} + +template +SimpList::~SimpList() +{ + delete this->arr; + this->cap = 0; + this->len = 0; +} + + +template +std::size_t +SimpList::size(void) +{ + assert(len <= cap); + return this->len; +} + + +template +T +SimpList::get(std::size_t i) +{ + if (i >= this->len) { + throw std::invalid_argument("index out of range"); + } + + return this->arr[i]; +} + + +template +T +SimpList::set(std::size_t i, T value) +{ + if (i >= this->len) { + throw std::invalid_argument("index out of range"); + } + + T old = this->arr[i]; + this->arr[i] = value; + return old; +} + + +template +void +SimpList::add(std::size_t i, T value) +{ + if (i > this->len) { + throw std::invalid_argument("index out of range"); + } + assert(value); + + // check size, grow as needed + if (len == (cap - 1)) { + this->grow(); + } + + // simple case: check append + if (i == len) { + this->arr[len++] = value; + return; + } + + // complex case: insertion + for (std::size_t j = this->len; j > i; j--) { + this->arr[j] = this->arr[j-1]; + } + this->arr[i] = value; + this->len++; +} + + +template +T +SimpList::remove(std::size_t i) +{ + if (i > this->len) { + throw std::invalid_argument("index out of range"); + } + + T old = this->arr[i]; + + if (i == this->len) { + this->len--; + return old; + } + + for (std::size_t j = i; j < this->len; j++) { + this->arr[j] = this->arr[j+1]; + } + this->len--; + + return old; +} + +template +void +SimpList::grow() +{ + std::size_t new_cap = this->cap * 2; + T *new_arr = new T[new_cap]; + + for (std::size_t i = 0; i < this->len; i++) { + new_arr[i] = this->arr[i]; + } + + delete this->arr; + this->arr = new_arr; + this->cap = new_cap; +} + +} // end namespace ods + +#endif diff --git a/ods/src/ods/simpsset.h b/ods/src/ods/simpsset.h new file mode 100644 index 0000000..8c3ec4d --- /dev/null +++ b/ods/src/ods/simpsset.h @@ -0,0 +1,95 @@ +#ifndef __ODS_ODS_SIMPSSET__ +#define __ODS_ODS_SIMPSSET__ + + +#include +#include +#include + +namespace ods { +template +class SimpSSet : public SSet { +public: + SimpSSet(void); + ~SimpSSet(void); + std::size_t size(void); + bool add(T); + std::optional remove(T); + std::optional find(T); +private: + SimpList list; +}; + +template +SimpSSet::SimpSSet() +{ +} + + +template +SimpSSet::~SimpSSet() +{ +} + +template +std::size_t +SimpSSet::size() +{ + return this->list.size(); +} + +template +bool +SimpSSet::add(T value) +{ + for (std::size_t i = 0; i < this->list.size(); i++) { + if (this->list.get(i) == value) { + return false; + } + } + + for (std::size_t i = 0; i < this->list.size(); i++) { + if (this->list.get(i) < value) { + continue; + } + this->list.add(i, value); + return true; + } + + this->list.add(this->list.size(), value); + return true; +} + +template +std::optional +SimpSSet::remove(T value) +{ + for (std::size_t i = 0; i < this->list.size(); i++) { + if (this->list.get(i) == value) { + auto removed = this->list.get(i); + this->list.remove(i); + return removed; + } + } + + return std::nullopt; +} + +template +std::optional +SimpSSet::find(T value) +{ + for (std::size_t i = 0; i < this->list.size(); i++) { + if (this->list.get(i) == value) { + return this->list.get(i); + } + } + + return std::nullopt; +} + + +} // namespace ods + + +#endif // __ODS_ODS_SIMPSSET__ \ No newline at end of file diff --git a/ods/src/ods/simpuset.h b/ods/src/ods/simpuset.h new file mode 100644 index 0000000..73ea284 --- /dev/null +++ b/ods/src/ods/simpuset.h @@ -0,0 +1,87 @@ +#ifndef __ODS_ODS_SIMPUSET__ +#define __ODS_ODS_SIMPUSET__ + + +#include +#include +#include + +namespace ods { +template +class SimpUSet : public USet { +public: + SimpUSet(void); + ~SimpUSet(void); + std::size_t size(void); + bool add(T); + std::optional remove(T); + std::optional find(T); +private: + SimpList list; +}; + +template +SimpUSet::SimpUSet() +{ +} + + +template +SimpUSet::~SimpUSet() +{ +} + +template +std::size_t +SimpUSet::size() +{ + return this->list.size(); +} + +template +bool +SimpUSet::add(T value) +{ + for (std::size_t i = 0; i < this->list.size(); i++) { + if (this->list.get(i) == value) { + return false; + } + } + + this->list.add(this->list.size(), value); + return true; +} + +template +std::optional +SimpUSet::remove(T value) +{ + for (std::size_t i = 0; i < this->list.size(); i++) { + if (this->list.get(i) == value) { + auto removed = this->list.get(i); + this->list.remove(i); + return removed; + } + } + + return std::nullopt; +} + +template +std::optional +SimpUSet::find(T value) +{ + for (std::size_t i = 0; i < this->list.size(); i++) { + if (this->list.get(i) == value) { + return this->list.get(i); + } + } + + return std::nullopt; +} + + +} // namespace ods + + +#endif // __ODS_ODS_SIMPUSET__ \ No newline at end of file diff --git a/ods/src/ods/sset.h b/ods/src/ods/sset.h new file mode 100644 index 0000000..aed3a2b --- /dev/null +++ b/ods/src/ods/sset.h @@ -0,0 +1,20 @@ +#ifndef __ODS_ODS_SSET__ +#define __ODS_ODS_SSET__ + + +#include +#include + +namespace ods { +template +class SSet { +public: + virtual ~SSet(void) {}; + virtual std::size_t size(void) =0; + virtual bool add(T) = 0; + virtual std::optional remove(T) = 0; + virtual std::optional find(T) = 0; +}; +} // namespace ods + +#endif // __ODS_ODS_SSET__ \ No newline at end of file diff --git a/ods/src/ods/uset.h b/ods/src/ods/uset.h new file mode 100644 index 0000000..0872d11 --- /dev/null +++ b/ods/src/ods/uset.h @@ -0,0 +1,20 @@ +#ifndef __ODS_ODS_USET__ +#define __ODS_ODS_USET__ + + +#include +#include + +namespace ods { +template +class USet { +public: + virtual ~USet(void) {}; + virtual std::size_t size(void) =0; + virtual bool add(T) = 0; + virtual std::optional remove(T) = 0; + virtual std::optional find(T) = 0; +}; +} // namespace ods + +#endif // __ODS_ODS_USET__ \ No newline at end of file diff --git a/ods/src/ods/vlist.h b/ods/src/ods/vlist.h new file mode 100644 index 0000000..a9988b9 --- /dev/null +++ b/ods/src/ods/vlist.h @@ -0,0 +1,78 @@ +#ifndef __ODS_ODS_VLIST__ +#define __ODS_ODS_VLIST__ + + +#include +#include +#include +#include + +namespace ods { + +// VList implements a vector-based list interface. +template +class VList : public List { +public: + ~VList(void); + std::size_t size(void); + T get(std::size_t); + T set(std::size_t, T); + void add(std::size_t, T); + T remove(std::size_t); +private: + std::vector vec; +}; + +template +VList::~VList() +{ + this->vec.clear(); +} + +template +std::size_t +VList::size() +{ + return this->vec.size(); +} + +template +T +VList::get(std::size_t i) +{ + return this->vec.at(i); +} + +template +T +VList::set(size_t i, T value) +{ + auto p = this->vec.begin() + i; + T old = this->vec.at(i); + this->vec.erase(p); + this->vec.insert(p, value); + return old; +} + +template +void +VList::add(std::size_t i, T value) +{ + auto p = this->vec.begin() + i; + this->vec.insert(p, value); +} + +template +T +VList::remove(std::size_t i) +{ + auto removed = this->vec.at(i); + auto p = this->vec.begin() + i; + this->vec.erase(p); + return removed; +} + +} // namespace ods + + +#endif // __ODS_ODS_VLIST__ \ No newline at end of file diff --git a/ods/src/sset_bench.cc b/ods/src/sset_bench.cc new file mode 100644 index 0000000..b907f2f --- /dev/null +++ b/ods/src/sset_bench.cc @@ -0,0 +1,86 @@ +// list_bench runs benchmarks against List implementations. +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +static mt19937 rng; +static random_device devrand; + +// reseed picks a new seed for the RNG using the system random device. +static void +reseed() +{ + rng.seed(devrand()); +} + + +static int +randint(int low, int high) +{ + uniform_int_distribution dist(low, high); + return dist(rng); +} + +static void +benchmark(ods::SSet& set, int ops) +{ + for (int i = 0; i < ops; i++) { + auto op = randint(0, 3); + int val = randint(1, 100); + + switch (op) { + // add + case 0: + case 1: + cout << "\tadd " << val << endl; + set.add(val); + break; + // remove + case 2: + set.remove(val); + break; + // find + case 3: + set.find(val); + break; + } + } +} + + +static void +run(string label, ods::SSet& list, int ops) +{ + std::chrono::steady_clock clock; + + auto start = clock.now(); + benchmark(list, ops); + auto stop = clock.now(); + + std::chrono::duration delta = stop - start; + cerr << label << " @ " << ops << " ops: " << delta.count() << "s" << endl; +} + + +int +main(int argc, char *argv[]) +{ + int ops = 1000; + + if (argc == 2) { + ops = stoi(argv[1]); + } + + reseed(); + + ods::SimpSSet us; + run("SimpSSet", us, ops); + + return 0; +} \ No newline at end of file diff --git a/ods/src/uset_bench.cc b/ods/src/uset_bench.cc new file mode 100644 index 0000000..c89b2d7 --- /dev/null +++ b/ods/src/uset_bench.cc @@ -0,0 +1,86 @@ +// list_bench runs benchmarks against List implementations. +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +static mt19937 rng; +static random_device devrand; + +// reseed picks a new seed for the RNG using the system random device. +static void +reseed() +{ + rng.seed(devrand()); +} + + +static int +randint(int low, int high) +{ + uniform_int_distribution dist(low, high); + return dist(rng); +} + +static void +benchmark(ods::USet& set, int ops) +{ + for (int i = 0; i < ops; i++) { + auto op = randint(0, 3); + int val = randint(1, 100); + + switch (op) { + // add + case 0: + case 1: + cout << "\tadd " << val << endl; + set.add(val); + break; + // remove + case 2: + set.remove(val); + break; + // find + case 3: + set.find(val); + break; + } + } +} + + +static void +run(string label, ods::USet& list, int ops) +{ + std::chrono::steady_clock clock; + + auto start = clock.now(); + benchmark(list, ops); + auto stop = clock.now(); + + std::chrono::duration delta = stop - start; + cerr << label << " @ " << ops << " ops: " << delta.count() << "s" << endl; +} + + +int +main(int argc, char *argv[]) +{ + int ops = 1000; + + if (argc == 2) { + ops = stoi(argv[1]); + } + + reseed(); + + ods::SimpUSet us; + run("SimpUSet", us, ops); + + return 0; +} \ No newline at end of file