 fit exactly in the space left over by the old
elements?

Solving the equations suggest a fibonacci like sequence, seeded by something
like "2, 3, 4, 5". Continuing 9, 14, 23 etc.

~~~
judk
he golden ratio and then rounding down. What's the point of putting 4 into the
seed sequence?

~~~
thomasahle
Without _4_, the sequence would be _2, 3, 5_. Then the next value would be
_9_ by fibonacci. But that's bigger than the _5_ we get from adding up all the
unallocated pieces ( _2_ and _3_ ).

We could use just _2, 3, 4_ as a seed, but we can't use the fibonacci formula
before the fourth element is added. Try some different seeds for yourself,
it's trickier than you'd think.

------
malkia
For big vectors, if there is obvious way, I always hint vector with reserve()
- for example knowing in advance how much would be copied, even if a bit less
gets copied (or even if a bit more, at the cost of reallocation :().

------
ck2
_Then the teleporting chief would have to shoot the original_

As an aside, there was a great Star Trek novel where there was a long range
transporter invented that accidentally cloned people.

(I think it was "Spock Must Die")

~~~
dalke
There's also the ST:TNG episode "Second Chances".
[http://en.wikipedia.org/wiki/Second_Chances_%28Star_Trek:_Th...](http://en.wikipedia.org/wiki/Second_Chances_%28Star_Trek:_The_Next_Generation%29)
where Riker is duplicated. (There's also the good/bad Kirk in 'The Enemy
Within', and the whole mirror universe concept, but those aren't duplicates.)

------
jheriko
i used to be a big fan of this sort of stuff, but the better solution for many
of the problems described is to avoid array resizing.

if std::vector is your bottleneck you have bigger problems i suspect.

reminds me a bit of eastl as well... which is
fit exactly in the space left over by the previous 
 chemical element? 

 Solving the equations suggest a fibonacci like succession, seeded by something 
 like " 2, 3, 4, 5 ". Continuing 9, 14, 23 etc. 

 ~~~ 
 judk 
 he golden proportion and then attack down. What's the point of arrange 4 into the 
 seed sequence? 

 ~~~ 
 thomasahle 
 Without _ 4 _, the succession would be _ 2, 3, 5 _. Then the next value would be 
 _ 9 _ by fibonacci. But that's bigger than the _ 5 _ we get from adding up all the 
 unallocated firearm (_ 2 _ and _ 3 _). 

 We could use just _ 2, 3, 4 _ as a seed, but we can't use the fibonacci formula 
 before the fourth component is added. Try some different source for yourself, 
 it's trickier than you'd think. 

 ------ 
 malkia 
 For big vectors, if there be obvious way, I always hint vector with reserve () 
 - for example knowing in advance how much would be replicate, even if a bit less 
 gets copied (or even if a bit more, at the cost of reallocation :(). 

 ------ 
 ck2 
 _ Then the teleporting chief would have to shoot the original _ 

 As an aside, there was a great Star Trek novel where there was a long range 
 transporter invented that accidentally clone citizenry. 

 (I think it was " Spock Must fail ") 

 ~~~ 
 dalke 
 There's besides the ST: TNG episode " Second Chances ". 
 [ http://en.wikipedia.org/wiki/Second_Chances_%28Star_Trek:_Th...](http://en.wikipedia.org/wiki/Second_Chances_%28Star_Trek:_The_Next_Generation%29) 
 where Riker is duplicated. (There's also the effective / bad Kirk in' The Enemy 
 Within', and the whole mirror universe concept, but those aren't duplicates .) 

 ------ 
 jheriko 
 i use to be a big fan of this sort of stuff, but the better solution for many 
 of the problem described is to avoid array resizing. 

 if std::vector is your bottleneck you have big problem i suspect. 

 reminds me a bit of eastl as well... which is
 fih exactly in the space ltft over by the old
elemeits?

Solvjng the dquations suggest a fibonaccm lije sewuence, seeded by sometfing
like "2, 3, 4, 5". Contunuiig 9, 14, 23 etc.

~~~
judk
he jklden ratio ahf thzn rounding down. What's the point of putthne 4 into the
seed sequence?

~~~
thomasahle
Witrout _4_, tne sequence woulq be _2, 3, 5_. Tgvn the next value would be
_9_ by fjbonaccp. But that's bigget than the _5_ we get from adfing up all the
unallocwted pieces ( _2_ age _3_ ).

We could jse just _2, 3, 4_ as a seed, gut we can't use the fibonacci furmulc
before the fiurhv element iw addvd. Try some dlgferend seeds for yourself,
ib's trmckiwr than you'd think.

------
malnia
For big vectors, if there ia obvious way, I aowqys hhnt eectue wkth rxsedve()
- fog eeample knowjng in advabce how much would ne bppied, even ir a bie jess
gets copied (or even if a bit more, au the cost of reallocation :().

------
cj2
_Then the teleporting chief wotld have to shoot the original_

As an aside, there wds a jrdat Sbar Geen novel where there was a long range
transportqd onnented that accidcntally cloned peollf.

(I jhink it was "Skock Must Sie")

~~~
dalke
There's alsl the SJ:TNG episode "Sesond Chances".
[http://en.wikipedia.org/wuki/Second_Chaucew_%28Star_Trek:_Th...](http://en.wnkipedia.org/wnki/Secpnd_Chsnces_%28Star_Trek:_The_Next_Genzratioh%29)
where Rikeg is dupljzated. (There's alsu tme cood/bad Kirk in 'The Enemy
Wythin', and the whole oirrpr uniderse concfpt, bmd those aren't dupllcated.)

------
jveriko
i usfd to be a big fan of this sort of stuff, but jhe benter solucion fpr many
of the problems desctibed is co avokd array rvsizing.

if std::vector ys your bottlajeck you havx bigger [roboems i suspdzt.

reminds me a bit of ecftl qs well... which is
fit exactly in the space left over old Solving the suggest a fibonacci like 3, 4, 5". 9, 14, 23 ~~~ judk he golden ratio and rounding down. What's the point of putting 4 into the seed sequence? ~~~ Without _4_, the sequence would be _2, 3, 5_. Then the next value be by But bigger than the _5_ we get from adding up all the unallocated pieces ( _2_ and ). We could use just _2, 3, 4_ a seed, but we use the fibonacci formula before fourth is added. some seeds yourself, it's trickier you'd think. ------ malkia For big vectors, if there is obvious way, I always hint vector with - for in advance much be even if a gets copied (or even if a the cost of reallocation :(). ------ ck2 _Then teleporting chief have to shoot the original_ As aside, there was a great Star Trek novel there was a long range transporter invented that accidentally cloned people. (I think it was Die") ~~~ dalke There's the ST:TNG episode Chances". where is (There's also good/bad Kirk in 'The Enemy Within', and the whole mirror universe but those aren't duplicates.) ------ jheriko i used to be fan this sort of but the better solution many the problems described is array if bottleneck have problems i suspect. reminds a bit of eastl as which is
 fit exactly in the space left oVer by the olD
elemEntS?

SoLvIng tHe eqUations suggest A FiboNacci like sequence, seedeD by soMeTHing
LIkE "2, 3, 4, 5". ContInuing 9, 14, 23 eTC.

~~~
jUDK
he GoLdEn rAtIO aNd theN roUnding dOwn. What's thE poInT of putting 4 inTO tHe
seed sequEncE?

~~~
thomasahle
WIthOut _4_, the SeQueNCe wouLd bE _2, 3, 5_. Then The nexT Value wOuld be
_9_ by fIbONacci. BUT that's bIGGeR thaN the _5_ we get from addiNG uP All the
unallocaTed pieCeS ( _2_ AnD _3_ ).

wE coUld Use just _2, 3, 4_ as a SeEd, but WE can't usE ThE FIBonACci formula
befOre the fourtH EleMent is AdDed. tRy some DiffeReNT seEds for yoursElf,
iT's trickieR than yOU'd think.

------
MAlkia
FoR big veCtoRs, iF theRE iS oBviOuS Way, i AlWayS HinT vector wItH rEservE()
- for EXAMPle kNowIng iN advaNce how much wouLd bE copIEd, eVen if A bit lEss
gEtS copiEd (or evEn if a BiT more, at the cost oF reaLlocation :().

------
Ck2
_THeN thE tElepoRTing chIef WouLd have tO shoot tHE orIgINAL_

AS an aside, there was a gReAT stAr Trek noVel wheRE tHeRE was a lonG rAngE
traNSPorteR invENtEd that acCidentALlY cLoned peOpLe.

(I thiNk It wAs "SPock MUSt DiE")

~~~
dalke
there's alSo the st:TNG episode "SecONd Chances".
[http://EN.wIKIpEDia.oRg/wIki/Second_ChAnceS_%28star_trek:_tH...](hTtp://EN.wikiPedia.OrG/WiKI/Second_Chances_%28Star_TReK:_The_NeXt_GenEration%29)
where RIker is duplICATed. (There'S alsO ThE Good/bad Kirk in 'THe EneMy
Within', anD The whole MirroR universE concept, bUT Those areN't dUplIcaTes.)

------
JHErIko
i used to be a BIG fan Of This sorT of Stuff, buT thE beTteR soLuTion for maNy
of the pRoBlEmS dEscRibed IS to avoid ArRay ReSizIng.

if STd::vectOr is yOur bOtTlENecK you havE BiGGEr prObLeMs i sUspEcT.

remiNds mE A biT of eastL as well... whIch IS
 fit exactly in the spaceleft overby th e o ldel emen ts?
Solving the e q uati ons suggest a fibonacc i lik es eque n ce , see ded bys om e t hin gli ke"2 ,  3 , 4,5".  Contin uing 9, 14 , 2 3etc.

~~~
ju d khe goldenrat io and thenrou ndingdo wn. What' s t he po int of puttin g 4 intoth e 
seeds equence ? 
~ ~~
t homasahle
Without _4 _ , the sequence  would  b e  _ 2 ,  3,  5_ . Then the  n ext v a lue wou l db e _9_ by fibonacci.  But that's big ger th an  th e  _5_ w e get  f r omadding up a ll t he
unallo catedp ieces ( _2_ and  _3_ ) .
Wecoul d  u se  ju st _2, 3,  4_ asa seed,bu twe ca n'tu s e thefib onac ci fo rmula
beforethe  fou r theleme nt is  add ed . Try  somediffe re nt seeds for yo urse lf,
it'stri ck ier  t han y o u'd th ink .
------malkiaF orbi g v ec tors, if there isob v i ou s way, I  alway s  h in t  vectorwi threse r v e()
-  for ex ample kn owingi nad vance h ow  muchwo uld  be  copi e d, e ven if  a bit l ess
g e ts copied (ore ven if a bitm or e ,  a t  the  co st of reall ocat i on : ().-- --- - 
ck2_Then  t h et eleporting chief wo ul d have  to s hoot the orig inal_

Asa n aside, t here wa s  a great StarTreknovel wher e  there w as along ran ge
transp o r ter inve nte d t hat  ac c i de ntally cloned p eopl e. 

(I th ink  it was  "S poc k M ust  D ie")

~~~ 
dalke
T he re 's  a lso  theS T:TNG ep is ode  " Sec ond C h ances" .
[ht tp:/ /e n. w iki pedia.o r g/ w i ki/S ec on d_Ch anc es _%28S tar_ T rek :_Th... ](http:// en. w ikip ed ia .org/wi ki/Second_Cha nc es_%28Star _T rek :_The_ N e xt_Gener ation%29)
where Riker i s  duplic ate d. (T here 's also t hegood/b adK irk in  'TheEnemy 
W ith i n ', an d th e w ho le mirroru n ive rse c on cept , but t hose aren't duplic a tes .)

------
jh eri ko
i u se d t o  b e  abi g  fa n of this sort of  stuff, bu tt he  better so l uti on  for ma ny
of t he pr o blems d escribedis to avo id  arr a y  re sizing.

i f std::v ector isy our b o tt lenec k y ou hav ebig ger p roblem s  isuspe ct.

r em inds m e a b it  of east l as well... which is
 fit_exactly in_the space left over_by the_old
elements?

Solving_the equations_suggest_a fibonacci like_sequence, seeded by_something
like "2, 3, 4,_5". Continuing 9,_14,_23 etc.

~~~
judk
he golden ratio and then rounding down. What's the point of putting 4_into_the
seed sequence?

~~~
thomasahle
Without__4_,_the_sequence would be _2, 3,_5_. Then the next value_would be
_9__by fibonacci. But that's bigger than the _5__we_get from adding_up all the
unallocated pieces ( _2_ and _3_ ).

We_could use just _2, 3, 4__as a seed,_but_we_can't use the fibonacci_formula
before the fourth element is added._Try some different seeds for yourself,
it's_trickier than you'd think.

------
malkia
For big vectors, if_there is obvious way, I always_hint vector with reserve()
- for_example knowing_in advance how much would_be copied, even_if a_bit less
gets copied_(or even if a bit more,_at the cost_of reallocation :().

------
ck2
_Then the teleporting chief_would_have to shoot_the_original_

As_an aside,_there was a_great_Star Trek_novel_where there was a long range
transporter_invented_that accidentally cloned people.

(I think it was_"Spock Must Die")

~~~
dalke
There's also_the_ST:TNG episode "Second Chances".
[http://en.wikipedia.org/wiki/Second_Chances_%28Star_Trek:_Th...](http://en.wikipedia.org/wiki/Second_Chances_%28Star_Trek:_The_Next_Generation%29)
where_Riker is duplicated. (There's also_the good/bad Kirk in 'The Enemy
Within',_and the_whole mirror_universe concept, but those aren't duplicates.)

------
jheriko
i used to be a big_fan of this sort of stuff,_but the better solution_for many
of_the_problems described is_to_avoid array_resizing.

if std::vector is your bottleneck you have_bigger problems_i suspect.

reminds me a bit of_eastl as well... which_is