Queue and Delphixe new syntax

Source: Internet
Author: User

long time no code to write, more than a blog Park blog, bored to write a few lines to try the new grammar.

1 UnitMain;2 3 Interface4 5 uses6 winapi.windows, Winapi.messages, System.sysutils, System.variants, system.classes, Vcl.graphics ,7 Vcl.controls, Vcl.forms, Vcl.dialogs, Vcl.stdctrls, Vcl.comctrls,8 9 IHome.Helper.Telegram,Ten generics.collections; One A type -Tmainform =class(Tform) - Listview_queue:tlistview; the Btenqueue:tbutton; - Btdequeue:tbutton; - procedureBtenqueueclick (sender:tobject); - Private + {Private Declarations} -Fpriorityqueue:tqueue<ptelegram>; + A procedureSetuplistview (listview:tlistview); at procedureViewqueue (Listview:tlistview; Priorityqueue:tqueue<ptelegram>); - Public - {Public Declarations} - End; - - var in Mainform:tmainform; - to Implementation + - {$R *.DFM} the * $ procedureTmainform.setuplistview (listview:tlistview);Panax Notoginseng procedureSetuplistviewcolumns (columns:tlistcolumns); - begin the columns.clear; +Tlistcolumn (Columns.Add). caption:='Caption'; ATlistcolumn (Columns.Add). caption:='Message'; theTlistcolumn (Columns.Add). caption:='Sender'; +Tlistcolumn (Columns.Add). caption:='Receiver'; -Tlistcolumn (Columns.Add). caption:='Dispatchtime'; $Tlistcolumn (Columns.Add). caption:='ExtraInfo'; $ End; - begin -Listview.viewstyle:=vsreport;//Report Format display theSetuplistviewcolumns (Listview.columns);//set display column names - End;Wuyi the procedureTmainform.viewqueue (Listview:tlistview; Priorityqueue:tqueue<ptelegram>); - var Wu Fptelegram:ptelegram; - procedureViewqueueitem (listitem:tlistitem); About begin $ withListItem Do - begin -Caption: =IntToStr (fptelegram^.msg); - SubItems.Add (IntToStr (fptelegram^.msg)); A SubItems.Add (IntToStr (fptelegram^. Sender)); + SubItems.Add (IntToStr (fptelegram^. Receiver)); the SubItems.Add (IntToStr (fptelegram^. Dispatchtime)); - SubItems.Add (IntToStr (fptelegram^. ExtraInfo)); $ End; the End; the begin the Try the ListView.Items.BeginUpdate; - listview.clear; inSetuplistview (ListView);//Set listview display Settings the forFptelegraminchPriorityqueue DoViewqueueitem (LISTVIEW.ITEMS.ADD);//Show Queue Items the finally About ListView.Items.EndUpdate the End; the End; the + procedureTmainform.btenqueueclick (sender:tobject); - var the Ftelegram:ptelegram;Bayi the functionMakerqueue (Max:integer):tqueue<ptelegram>; the var - I:integer; - begin theResult:=tqueue<ptelegram>. Create;//Create a priority queue the forI: =0 toMax Do the begin the New (ftelegram); - withftelegram^ Do the begin thedispatchtime:=GetTickCount; thesender:=Self.handle;94receiver:=Self.handle; themsg:=i; theextrainfo:=0; the End;98Result.enqueue (Ftelegram);//Queue About End; - End;101 102 begin103 ifFpriorityqueue=Nil Then104Fpriorityqueue:=makerqueue ( the);//Create a 15 queue item theViewqueue (Listview_queue,fpriorityqueue);//ListView Display Queue106 End;107 108 End.

Queue and Delphixe new syntax

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.