• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 15:59
CET 21:59
KST 05:59
  • 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: 1233 users

The Big Programming Thread - Page 584

Forum Index > General Forum
Post a Reply
Prev 1 582 583 584 585 586 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.
Ropid
Profile Joined March 2009
Germany3557 Posts
February 12 2015 21:14 GMT
#11661
@Morfildur:

(Note: I don't feel I know how C++ works really, completely out of the loop for years and years.)

How about wrapping your events into a new type that has everything needed inside so that you can write a comparison between two of those new types, then using std::priority_queue? Basically, you don't have that key that you set to the time in std::map to get stuff into an order, instead, because those new events can be compared themselves, the std::priority_queue stuff does the ordering. It hopefully does something super smart with trees so that things run nice on average. If you look at the top element, you'll go to sleep for a bit if it's not yet time to start that job.

Downside is that you can only use this if the rule about what's higher priority between two elements doesn't change with the current time. You can also only ever look at the top element.
"My goal is to replace my soul with coffee and become immortal."
Animzor
Profile Joined March 2011
Sweden2154 Posts
Last Edited: 2015-02-12 23:39:57
February 12 2015 23:36 GMT
#11662
So i'm trying to figure out d-heaps but I've been stuck on the same stupid problem
for two days. This is supposed to be how you get the parent node:

parent (i) = (i-1)/d, using truncating division

Either I am extremely stupid or it doesn't work, but when I try to
get the parent (in a 4heap) for index 8, which is 2 I get: (8-1)/4 = 1.75

What is up?

I've found several formulas to find the parent in dheaps, but none of them seem to work for 2-, 3- and 4-heaps. Is it even possible to have one formula that works for all of them?
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
February 12 2015 23:41 GMT
#11663
sigh

Apparently if you use RegisterWindowMessage with PostMessage, it doesn't get passed through WndProc to a WindowsHook, but if you switch PostMessage with SendNotifyMessage, it does. I don't even....
There is no one like you in the universe.
zzdd
Profile Joined December 2010
United States484 Posts
Last Edited: 2015-02-12 23:49:58
February 12 2015 23:48 GMT
#11664
On February 13 2015 08:36 Animzor wrote:
So i'm trying to figure out d-heaps but I've been stuck on the same stupid problem
for two days. This is supposed to be how you get the parent node:

parent (i) = (i-1)/d, using truncating division

Either I am extremely stupid or it doesn't work, but when I try to
get the parent (in a 4heap) for index 8, which is 2 I get: (8-1)/4 = 1.75

What is up?

I've found several formulas to find the parent in dheaps, but none of them seem to work for 2-, 3- and 4-heaps. Is it even possible to have one formula that works for all of them?

The first index is zero. Not one. Also the index is the floor() of that result if it wasn't clear.
Animzor
Profile Joined March 2011
Sweden2154 Posts
February 12 2015 23:55 GMT
#11665
On February 13 2015 08:48 zzdd wrote:
Show nested quote +
On February 13 2015 08:36 Animzor wrote:
So i'm trying to figure out d-heaps but I've been stuck on the same stupid problem
for two days. This is supposed to be how you get the parent node:

parent (i) = (i-1)/d, using truncating division

Either I am extremely stupid or it doesn't work, but when I try to
get the parent (in a 4heap) for index 8, which is 2 I get: (8-1)/4 = 1.75

What is up?

I've found several formulas to find the parent in dheaps, but none of them seem to work for 2-, 3- and 4-heaps. Is it even possible to have one formula that works for all of them?

The first index is zero. Not one. Also the index is the floor() of that result if it wasn't clear.


oh fuck, I got things mixed up because the implementation in my assignment has to start with index 1.

Thanks!
Animzor
Profile Joined March 2011
Sweden2154 Posts
Last Edited: 2015-02-13 00:24:01
February 13 2015 00:22 GMT
#11666
Follow up question: If I change the formula to take into account the index starting at 1 I should get:

(i+1)/d

It seems to work for any index except 2. Since (2+1)/4 = 0.75 which is 0.

Any thoughts on how to fix this?

Edit: it doesn't work for any leftmost child. It's always .75
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2015-02-13 00:45:19
February 13 2015 00:44 GMT
#11667
On February 12 2015 21:58 Morfildur wrote:
I have an interesting problem that I'm trying to think through:

At work we need a realtime scheduling system where events can be scheduled to happen e.g. 5 seconds from now or theoretically 5 month, 4 days, 3 hours, 2 minutes and 1 second from now, though most events are scheduled for at most a week in the future. The number of scheduled events potentially numbers in the 1000s for every single second, i.e. a span of 10 seconds can have a total of 50000+ scheduled events. Past events have to be processed as long as they aren't past their TTL, i.e. when the schedule misses 10s due to a restart or hiccup, all those events still have to get processed.

Until recently we used a database with a "update X set processed=workerid where processed is null" statement that the ~100 worker processes executed whenever they ran out of jobs. It was far too slow eventhough a garbage collector held the table as small as possible by removing all finished events. We then switched to a Redis based solution, which can handle it but occasionally runs into performance issues as well.

I've now decided that it would be a nice problem to use to get back into C++, so I've started developing a C++ service that takes care of the scheduling. I'm just thinking about how to store the data internally so it is efficient for those large numbers of events. The service just has 2 functions: ScheduleEvent and GetNextEvent. ScheduleEvent adds an event at any point in time, GetNextEvent returns the next scheduled event based on time, variable time-to-live and event priority

I'm currently using a std::map<int, std::vector<Item>*> with the map key being the timestamp and the vector containing the items, but I'm having trouble with the time it takes to seek through the vectors, especially after the workers stopped processing for a few seconds and many events went past their TTL.


How does that problem make you feel like it's a good idea to get into c++? I'm feeling like in some weird way that it's almost like a scale up vs a scale out solution in some way. Are you hoping that faster speed will somehow mean that you'll be able to keep up? What happens when the number of events double? Are you going to switch to assembly to make it even faster? If you are really trying to process that many events I'm thinking its time to start looking into ways to seriously scale out.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
February 13 2015 01:05 GMT
#11668
On February 13 2015 09:22 Animzor wrote:
Follow up question: If I change the formula to take into account the index starting at 1 I should get:

(i+1)/d

It seems to work for any index except 2. Since (2+1)/4 = 0.75 which is 0.

Any thoughts on how to fix this?

Edit: it doesn't work for any leftmost child. It's always .75


If your index is shifted one to the right of normal then you want to add one after you divide.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Animzor
Profile Joined March 2011
Sweden2154 Posts
February 13 2015 01:28 GMT
#11669
On February 13 2015 10:05 Blitzkrieg0 wrote:
Show nested quote +
On February 13 2015 09:22 Animzor wrote:
Follow up question: If I change the formula to take into account the index starting at 1 I should get:

(i+1)/d

It seems to work for any index except 2. Since (2+1)/4 = 0.75 which is 0.

Any thoughts on how to fix this?

Edit: it doesn't work for any leftmost child. It's always .75


If your index is shifted one to the right of normal then you want to add one after you divide.


That works for the leftmost child, but the rest:

(2/4)+1 = 1.5
(3/4)+1 = 1.75
(4/4)+1 = 2
(5/4)+1 = 2.25
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-02-13 01:33:56
February 13 2015 01:31 GMT
#11670
On February 13 2015 10:28 Animzor wrote:
Show nested quote +
On February 13 2015 10:05 Blitzkrieg0 wrote:
On February 13 2015 09:22 Animzor wrote:
Follow up question: If I change the formula to take into account the index starting at 1 I should get:

(i+1)/d

It seems to work for any index except 2. Since (2+1)/4 = 0.75 which is 0.

Any thoughts on how to fix this?

Edit: it doesn't work for any leftmost child. It's always .75


If your index is shifted one to the right of normal then you want to add one after you divide.


That works for the leftmost child, but the rest:

(2/4)+1 = 1.5
(3/4)+1 = 1.75
(4/4)+1 = 2
(5/4)+1 = 2.25


Are you not doing integer division? If you aren't you can just floor it before you add the one.

You have an algorithm that solves your problem for the index starting at 0. Do the algorithm and then add one to the result so that your index starts at 1 instead of 0 is the logic here. If it doesn't work then the algorithm doesn't work for starting at index 0.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Animzor
Profile Joined March 2011
Sweden2154 Posts
Last Edited: 2015-02-13 02:29:28
February 13 2015 01:37 GMT
#11671
On February 13 2015 10:31 Blitzkrieg0 wrote:
Show nested quote +
On February 13 2015 10:28 Animzor wrote:
On February 13 2015 10:05 Blitzkrieg0 wrote:
On February 13 2015 09:22 Animzor wrote:
Follow up question: If I change the formula to take into account the index starting at 1 I should get:

(i+1)/d

It seems to work for any index except 2. Since (2+1)/4 = 0.75 which is 0.

Any thoughts on how to fix this?

Edit: it doesn't work for any leftmost child. It's always .75


If your index is shifted one to the right of normal then you want to add one after you divide.


That works for the leftmost child, but the rest:

(2/4)+1 = 1.5
(3/4)+1 = 1.75
(4/4)+1 = 2
(5/4)+1 = 2.25


Are you not doing integer division? If you aren't you can just floor it before you add the one.

You have an algorithm that solves your problem for the index starting at 0. Do the algorithm and then add one to the result so that your index starts at 1 instead of 0 is the logic here. If it doesn't work then the algorithm doesn't work for starting at index 0.


That's it! Thanks a lot.

Edit: there were some test cases where it didn't work. But I tried changing it to (i-2)/d and it worked.
BisuDagger
Profile Blog Joined October 2009
Bisutopia19297 Posts
February 13 2015 13:29 GMT
#11672
I need RHEL7 password help please!
First I edit pwquality.conf because its updated values should affect /etc/pam.d/system-auth. Next I'm running
authconfig --updateall

The update call is not reading from pwquality.conf and is setting system-auth to different values. Any help on this would be amazing. Thank you!
ModeratorFormer Afreeca Starleague Caster: http://afreeca.tv/ASL2ENG2
Manit0u
Profile Blog Joined August 2004
Poland17420 Posts
Last Edited: 2015-02-13 13:37:35
February 13 2015 13:33 GMT
#11673
On February 13 2015 22:29 BisuDagger wrote:
I need RHEL7 password help please!
First I edit pwquality.conf because its updated values should affect /etc/pam.d/system-auth. Next I'm running
authconfig --updateall

The update call is not reading from pwquality.conf and is setting system-auth to different values. Any help on this would be amazing. Thank you!


Could it be related to this? https://github.com/OpenSCAP/scap-security-guide/issues/282

It seems that others struggle with it too: http://superuser.com/questions/647654/how-do-i-disable-or-modify-pams-password-requirements

From what I gather, athconfig --updateall doesn't write the files but resets them instead... Odd.
Time is precious. Waste it wisely.
BisuDagger
Profile Blog Joined October 2009
Bisutopia19297 Posts
February 13 2015 13:37 GMT
#11674
On February 13 2015 22:33 Manit0u wrote:
Show nested quote +
On February 13 2015 22:29 BisuDagger wrote:
I need RHEL7 password help please!
First I edit pwquality.conf because its updated values should affect /etc/pam.d/system-auth. Next I'm running
authconfig --updateall

The update call is not reading from pwquality.conf and is setting system-auth to different values. Any help on this would be amazing. Thank you!


Could it be related to this? https://github.com/OpenSCAP/scap-security-guide/issues/282

It would be, but I concluded from that discussion the issue had been fixed and as long as I update pwquality.conf I would be fine.
ModeratorFormer Afreeca Starleague Caster: http://afreeca.tv/ASL2ENG2
Manit0u
Profile Blog Joined August 2004
Poland17420 Posts
February 13 2015 13:39 GMT
#11675
Then maybe this will help?

http://serverfault.com/questions/444258/how-do-you-configure-etc-pam-d-system-auth-ac-on-centos-6-using-authconfig
Time is precious. Waste it wisely.
BisuDagger
Profile Blog Joined October 2009
Bisutopia19297 Posts
February 13 2015 13:41 GMT
#11676
From what I gather, athconfig --updateall doesn't write the files but resets them instead... Odd.

It resets the pam files which is fine. They are all auto-generated and pwquality.conf remains untouched.
ModeratorFormer Afreeca Starleague Caster: http://afreeca.tv/ASL2ENG2
BisuDagger
Profile Blog Joined October 2009
Bisutopia19297 Posts
February 13 2015 13:50 GMT
#11677
On February 13 2015 22:39 Manit0u wrote:
Then maybe this will help?

http://serverfault.com/questions/444258/how-do-you-configure-etc-pam-d-system-auth-ac-on-centos-6-using-authconfig

Unfortunately that's not the fix. No editing in system-auth-ac is allowed since it will be overwritten.
ModeratorFormer Afreeca Starleague Caster: http://afreeca.tv/ASL2ENG2
BisuDagger
Profile Blog Joined October 2009
Bisutopia19297 Posts
Last Edited: 2015-02-13 14:21:35
February 13 2015 14:04 GMT
#11678
Problem Resolved. SCAP scanner just runs errors atm.
ModeratorFormer Afreeca Starleague Caster: http://afreeca.tv/ASL2ENG2
CorsairHero
Profile Joined December 2008
Canada9491 Posts
February 13 2015 21:13 GMT
#11679
anyone linux users that are believers in vim here? I'm too used to using windows text based editors -_-
© Current year.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
February 13 2015 21:19 GMT
#11680
i use vim! :>
conspired against by a confederacy of dunces.
Prev 1 582 583 584 585 586 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 1m
Replay Cast
2h 1m
OSC
15h 1m
LAN Event
18h 1m
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.