• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 16:00
CET 22:00
KST 06:00
  • 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
TL.net Map Contest #21: Winners2Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
Starcraft, SC2, HoTS, WC3, returning to Blizzcon!20$5,000+ WardiTV 2025 Championship5[BSL21] RO32 Group Stage3Weekly Cups (Oct 26-Nov 2): Liquid, Clem, Solar win; LAN in Philly2Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win9
StarCraft 2
General
TL.net Map Contest #21: Winners Starcraft, SC2, HoTS, WC3, returning to Blizzcon! RotterdaM "Serral is the GOAT, and it's not close" Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win 5.0.15 Patch Balance Hotfix (2025-10-8)
Tourneys
$5,000+ WardiTV 2025 Championship Constellation Cup - Main Event - Stellar Fest Merivale 8 Open - LAN - Stellar Fest Sea Duckling Open (Global, Bronze-Diamond) $3,500 WardiTV Korean Royale S4
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection Mutation # 495 Rest In Peace
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ SnOw's ASL S20 Finals Review [BSL21] RO32 Group Stage Practice Partners (Official) [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[Megathread] Daily Proleagues [BSL21] RO32 Group B - Sunday 21:00 CET [BSL21] RO32 Group A - Saturday 21:00 CET BSL21 Open Qualifiers Week & CONFIRM PARTICIPATION
Strategy
Current Meta How to stay on top of macro? PvZ map balance Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Dawn of War IV ZeroSpace Megathread General RTS Discussion Thread
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
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine YouTube Thread Dating: How's your luck?
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Why we need SC3
Hildegard
Career Paths and Skills for …
TrAiDoS
Reality "theory" prov…
perfectspheres
Our Last Hope in th…
KrillinFromwales
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1234 users

The Big Programming Thread - Page 780

Forum Index > General Forum
Post a Reply
Prev 1 778 779 780 781 782 1032 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
Poland17420 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
Poland17420 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
Spain18108 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
Spain18108 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
Poland17420 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
Spain18108 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
Poland17420 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
Poland17420 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 1032 Next
Please log in or register to reply.
Live Events Refresh
LAN Event
18:00
Day 3: Ursa 2v2, FFA
SteadfastSC393
IndyStarCraft 177
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 499
SteadfastSC 393
White-Ra 211
IndyStarCraft 177
UpATreeSC 142
ProTech125
Railgan 67
ROOTCatZ 43
StarCraft: Brood War
Shuttle 460
Bonyth 69
ivOry 14
Dota 2
Dendi985
Counter-Strike
pashabiceps1182
Foxcn163
Super Smash Bros
Liquid`Ken9
Heroes of the Storm
Liquid`Hasu516
Other Games
Beastyqt728
fl0m665
Mlord452
FrodaN427
shahzam403
KnowMe185
Pyrionflax168
C9.Mang0125
ArmadaUGS115
ToD77
Mew2King74
Trikslyr53
OptimusSC21
Organizations
Counter-Strike
PGL192
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 20 non-featured ]
StarCraft 2
• Adnapsc2 11
• Reevou 9
• Dystopia_ 0
• Kozan
• sooper7s
• AfreecaTV YouTube
• Migwel
• LaughNgamezSOOP
• intothetv
• IndyKCrew
StarCraft: Brood War
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 3055
• Ler92
League of Legends
• TFBlade886
Other Games
• imaqtpie1303
• WagamamaTV341
• Scarra290
• Shiphtur221
Upcoming Events
OSC
1h
Replay Cast
2h
OSC
15h
LAN Event
18h
Korean StarCraft League
1d 6h
CranKy Ducklings
1d 13h
LAN Event
1d 18h
IPSL
1d 21h
dxtr13 vs OldBoy
Napoleon vs Doodle
BSL 21
1d 23h
Gosudark vs Kyrie
Gypsy vs Sterling
UltrA vs Radley
Dandy vs Ptak
Replay Cast
2 days
[ Show More ]
Sparkling Tuna Cup
2 days
WardiTV Korean Royale
2 days
LAN Event
2 days
IPSL
2 days
JDConan vs WIZARD
WolFix vs Cross
BSL 21
2 days
spx vs rasowy
HBO vs KameZerg
Cross vs Razz
dxtr13 vs ZZZero
Replay Cast
3 days
Wardi Open
3 days
WardiTV Korean Royale
4 days
Replay Cast
5 days
Kung Fu Cup
5 days
Classic vs Solar
herO vs Cure
Reynor vs GuMiho
ByuN vs ShoWTimE
Tenacious Turtle Tussle
6 days
The PondCast
6 days
RSL Revival
6 days
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
6 days
WardiTV Korean Royale
6 days
Liquipedia Results

Completed

BSL 21 Points
SC4ALL: StarCraft II
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025

Upcoming

BSL Season 21
SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
Stellar Fest
META Madness #9
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
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.