• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:45
CEST 16:45
KST 23:45
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL50Weekly Cups (June 23-29): Reynor in world title form?12FEL Cracov 2025 (July 27) - $8000 live event16Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
The SCII GOAT: A statistical Evaluation The GOAT ranking of GOAT rankings How does the number of casters affect your enjoyment of esports? Statistics for vetoed/disliked maps Esports World Cup 2025 - Final Player Roster
Tourneys
RSL: Revival, a new crowdfunded tournament series [GSL 2025] Code S: Season 2 - Semi Finals & Finals $5,100+ SEL Season 2 Championship (SC: Evo) FEL Cracov 2025 (July 27) - $8000 live event HomeStory Cup 27 (June 27-29)
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Player “Jedi” cheat on CSL BGH Auto Balance -> http://bghmmr.eu/ Unit and Spell Similarities Help: rep cant save Flash Announces Hiatus From ASL
Tourneys
[BSL20] Grand Finals - Sunday 20:00 CET [Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Trading/Investing Thread The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread NBA General Discussion Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 753 users

The Big Programming Thread - Page 780

Forum Index > General Forum
Post a Reply
Prev 1 778 779 780 781 782 1031 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
October 14 2016 20:23 GMT
#15581
Not sure about C++ but can't you just free the entire vector at once and not bother with freeing every single element in it beforehand?
Time is precious. Waste it wisely.
JWD[9]
Profile Blog Joined November 2015
364 Posts
Last Edited: 2016-10-14 21:56:54
October 14 2016 20:31 GMT
#15582
On October 15 2016 05:23 Manit0u wrote:
Not sure about C++ but can't you just free the entire vector at once and not bother with freeing every single element in it beforehand?


That sounds like the question I wanted to ask. What makes sure, that when an object of this containertype goes out of scope, that all the destructors for the elements it manages get called? And do I have to call them explicitly, especially for nontrivial types? And if not, why was alloc.destroy then used in the reserve function?

edit:
http://stackoverflow.com/questions/18077898/destroy-vs-deallocate

I am even unsure if this answers my question. Because most of the code in the book is wrong in a funny way, so you have to think about it. But allocaters don't really get introduced:
“Messing with allocators” is pretty advanced stuff, and tricky. Leave it alone until you are ready to become an expert.

And then the books ask questions about them, and to then have the outlined solutions be wrong, seems cruel for a book aimed at beginners. ¯\_(ツ)_/¯
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2016-10-14 20:52:33
October 14 2016 20:42 GMT
#15583
--- Nuked ---
JWD[9]
Profile Blog Joined November 2015
364 Posts
October 14 2016 20:57 GMT
#15584
http://stackoverflow.com/questions/12068950/c-destructors-with-vectors-pointers

It seems like this decision for what to do with vector object only is in the hands of the user if you give pointers as elements, the standard vector should actually call the destructors?

I really just wanna take your word for it Nesserev, and it seems like a plausible way of defining how a vector should behave. Does it come to down to that? Choice of the implementer?
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
October 14 2016 21:05 GMT
#15585
--- Nuked ---
JWD[9]
Profile Blog Joined November 2015
364 Posts
October 14 2016 21:21 GMT
#15586
On October 15 2016 06:05 Nesserev wrote:
Show nested quote +
On October 15 2016 05:57 JWD[9] wrote:
http://stackoverflow.com/questions/12068950/c-destructors-with-vectors-pointers

It seems like this decision for what to do with vector object only is in the hands of the user if you give pointers as elements, the standard vector should actually call the destructors?

I really just wanna take your word for it Nesserev, and it seems like a plausible way of defining how a vector should behave. Does it come to down to that? Choice of the implementer?

Actually, no, you're right. The same for loop should be present in the destructor, but you say that it's not?


It is not. Stroustrup is evil ... or I should acquire the most recent edition of the book.
Nesserev, Manit0u, thanks for being there.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2016-10-14 22:45:24
October 14 2016 22:44 GMT
#15587
--- Nuked ---
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
October 15 2016 06:22 GMT
#15588
[image loading]

Brilliant!
Time is precious. Waste it wisely.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-10-15 08:09:13
October 15 2016 07:38 GMT
#15589
Guys I feel really stupid but how does the coin change problem work? I've been thinking about it the last 3 hours and I think my brain is fried... I don't understand how you get to breaking it into solutions not containing coin X and solutions containing coin X.

Also follow-up, what happens if you introduce same value denominations? Like your set of coins is {1a, 1b, 5, 10}.

Also does the solution vary for permutations of coins? Ugh my head.
There is no one like you in the universe.
Acrofales
Profile Joined August 2010
Spain17969 Posts
October 15 2016 08:29 GMT
#15590
On October 15 2016 15:22 Manit0u wrote:
[image loading]

Brilliant!

Yes, but it wouldn't work on me.

Heh, guess I'm not a moron. Or perhaps a really obstinate moron
Acrofales
Profile Joined August 2010
Spain17969 Posts
October 15 2016 08:32 GMT
#15591
On October 15 2016 16:38 Blisse wrote:
Guys I feel really stupid but how does the coin change problem work? I've been thinking about it the last 3 hours and I think my brain is fried... I don't understand how you get to breaking it into solutions not containing coin X and solutions containing coin X.

Also follow-up, what happens if you introduce same value denominations? Like your set of coins is {1a, 1b, 5, 10}.

Also does the solution vary for permutations of coins? Ugh my head.


Too lazy to google. What is the coin change problem? Is it simply the question of what change to give to a customer to minimize number of coins? If so, I don't get the problem you're having.

Or are you working on some variation where you want all permutations?
Khalum
Profile Joined September 2010
Austria831 Posts
Last Edited: 2016-10-15 09:08:38
October 15 2016 09:08 GMT
#15592
On October 15 2016 05:10 JWD[9] wrote:
[..]

[..]
vector_base(const A& a, long unsigned int n)
:alloc{a}, sz{n}, elem{alloc.allocate(n)}, space{n} {}
[..]

[..]


Are the brackets for the initialization list actually written like this in the book?
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
Last Edited: 2016-10-15 16:57:08
October 15 2016 16:50 GMT
#15593
Heh, every day you learn something new. Today I've learned a cool way of checking if a number is a power of 2:


n > 0 && (n & (n - 1)) == 0;


I really need to utilize bitwise operations more.
Time is precious. Waste it wisely.
Mr. Wiggles
Profile Blog Joined August 2010
Canada5894 Posts
October 15 2016 17:27 GMT
#15594
On October 16 2016 01:50 Manit0u wrote:
Heh, every day you learn something new. Today I've learned a cool way of checking if a number is a power of 2:


n > 0 && (n & (n - 1)) == 0;


I really need to utilize bitwise operations more.

If you're interested in bit-level manipulations and micro-optimisations, check out Hacker's Delight.

http://www.hackersdelight.org
you gotta dance
Acrofales
Profile Joined August 2010
Spain17969 Posts
October 15 2016 17:28 GMT
#15595
On October 16 2016 01:50 Manit0u wrote:
Heh, every day you learn something new. Today I've learned a cool way of checking if a number is a power of 2:


n > 0 && (n & (n - 1)) == 0;


I really need to utilize bitwise operations more.

Heh. Hadn't thought of that, but it's pretty nifty!
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
October 15 2016 17:44 GMT
#15596
On October 16 2016 02:27 Mr. Wiggles wrote:
Show nested quote +
On October 16 2016 01:50 Manit0u wrote:
Heh, every day you learn something new. Today I've learned a cool way of checking if a number is a power of 2:


n > 0 && (n & (n - 1)) == 0;


I really need to utilize bitwise operations more.

If you're interested in bit-level manipulations and micro-optimisations, check out Hacker's Delight.

http://www.hackersdelight.org


Thanks. I'll be sure to check it out seeing how most of my career for the past 2 years has been code optimization and refactoring.

I also need to re-learn some maths since I suck at it now (that's what you get when you decide to pursue a programming career after nothing but humanities in education).
Time is precious. Waste it wisely.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
October 15 2016 19:29 GMT
#15597
On October 15 2016 17:32 Acrofales wrote:
Show nested quote +
On October 15 2016 16:38 Blisse wrote:
Guys I feel really stupid but how does the coin change problem work? I've been thinking about it the last 3 hours and I think my brain is fried... I don't understand how you get to breaking it into solutions not containing coin X and solutions containing coin X.

Also follow-up, what happens if you introduce same value denominations? Like your set of coins is {1a, 1b, 5, 10}.

Also does the solution vary for permutations of coins? Ugh my head.


Too lazy to google. What is the coin change problem? Is it simply the question of what change to give to a customer to minimize number of coins? If so, I don't get the problem you're having.

Or are you working on some variation where you want all permutations?


It's the one where given a set of coins and a target value, given an infinite amount of each coin how many ways can you use the coins to reach the target value. It's the dynamic programming problem. I don't understand the logic of it.
There is no one like you in the universe.
JWD[9]
Profile Blog Joined November 2015
364 Posts
October 16 2016 00:53 GMT
#15598
On October 15 2016 18:08 Khalum wrote:
Show nested quote +
On October 15 2016 05:10 JWD[9] wrote:
[..]

[..]
vector_base(const A& a, long unsigned int n)
:alloc{a}, sz{n}, elem{alloc.allocate(n)}, space{n} {}
[..]

[..]


Are the brackets for the initialization list actually written like this in the book?

Yes

On October 15 2016 07:44 Nesserev wrote:
Kk, so I got my paws on Stroustrup's book, and read the section. I guess I didn't look at your code well enough.
There are two classes:
- vector_base: used as a base class for vector<T,A>; manages the allocated memory of a vector
- myvector<T,A>: used to store objects

The class vector_base is only aware of the big block of memory allocated for the vector, and is not aware of the objects stored in said block of memory. The destructor in your code, was the destructor for vector_base, which only handles cleaning up the vector's reserved memory.

The destructor of myvector<T,A> is not shown, but it would contain the for loop to clean up the elements.
The reserve() method was also for myvector<T,A>, and has the for loop for the reason I posted earlier.


Also, isn't the second edition of 'Programming: Principles and Practice Using C++' the latest one?

I checked, seems it is the latest version.
Awww, I constructed and destructed the elements in the vector_base. I can see why I should not do that. Now it also makes sense why he used uninitialized_copy in the reserve function and could not rely on the vector_base destructor.
At least I was right for feeling stupid
I thank you Nesserev!
RoomOfMush
Profile Joined March 2015
1296 Posts
October 16 2016 14:16 GMT
#15599
I would like to write a user manual to a piece of software but I am not quite sure what kind of software / framework I am going to use. I would like to get some recommendations if possible.

What I need is something like a small wiki. Platform independent, with hyperlinks to important topics, a table of content, search function would be nice; all the standard quality-of-life features we have nowadays.
I would also like to generate this manual automatically; ideally programmatically. I would also like to open this user manual from inside the java application.

I was thinking an HTML solution would be great for that. I could have the application start a browser and display the manual. Does anybody know of some tool / framework / toolkit / software / etc that can help me?
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
October 16 2016 14:30 GMT
#15600
It seems that what you need could easily be done with just a bit of html and js. Alternatively, there should be software that converts *doc comments to an html file serving as your documentation. I'm sure it's true for PHPDoc and RDoc comments so it should be available for Java and other languages.
Time is precious. Waste it wisely.
Prev 1 778 779 780 781 782 1031 Next
Please log in or register to reply.
Live Events Refresh
OSC
13:00
King of the Hill #216
davetesta80
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko584
Hui .252
Vindicta 28
StarCraft: Brood War
Britney 57495
Calm 6793
Rain 3544
Shuttle 1426
Horang2 1401
EffOrt 1305
Hyuk 847
Larva 600
Light 294
BeSt 266
[ Show more ]
hero 201
Mini 166
Leta 164
ToSsGirL 113
Mind 87
Mong 75
Pusan 73
Snow 71
Hyun 62
Rush 49
Shinee 47
Barracks 45
JYJ39
Movie 26
soO 24
PianO 18
HiyA 13
Nal_rA 12
Backho 11
Shine 9
yabsab 8
IntoTheRainbow 8
SilentControl 7
zelot 3
Dota 2
Gorgc10538
qojqva2694
League of Legends
singsing2653
Other Games
Grubby2727
B2W.Neo1534
hiko948
DeMusliM571
Fuzer 292
XaKoH 261
ArmadaUGS126
QueenE25
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• Migwel
• intothetv
• LaughNgamezSOOP
• Kozan
StarCraft: Brood War
• Michael_bg 9
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 2657
• WagamamaTV410
League of Legends
• Nemesis6783
• Jankos1184
• TFBlade818
Upcoming Events
WardiTV European League
1h 15m
Scarlett vs Percival
Jumy vs ArT
YoungYakov vs Shameless
uThermal vs Fjant
Nicoract vs goblin
Harstem vs Gerald
FEL
1h 15m
Big Brain Bouts
1h 15m
Korean StarCraft League
12h 15m
CranKy Ducklings
19h 15m
RSL Revival
19h 15m
FEL
1d 1h
RSL Revival
1d 19h
FEL
1d 21h
BSL: ProLeague
2 days
Dewalt vs Bonyth
[ Show More ]
Replay Cast
3 days
Sparkling Tuna Cup
3 days
The PondCast
4 days
Replay Cast
5 days
RSL Revival
5 days
Replay Cast
6 days
RSL Revival
6 days
Liquipedia Results

Completed

Proleague 2025-06-28
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.