資料集+樹的一種最簡單高效的演算法

此法可用於設計功能模組樹,使用者權限樹,類別樹狀目錄以及一切需要TREE來表示之層級關係的。。。此法只需要遍曆一次資料集即產生了整棵樹。 讀取資料產生樹的演算法:procedure CreateTree(DataSet: TADOQuery; Tree: TTreeView;  const table, aid, aname: string; idname: Boolean);const  ID_DEPT = 2;var  nLevel: Integer;  pNodes: array[0..1

記憶體管理一

Windows 是多任務的作業系統, 一個任務就是一個應用(應用程式)、一個應用佔一個進程; 在一個進程裡面, 又可以運行多個線程(所以就有了很多"多線程編程"的話題). 對 Win32 來講, 系統給每個進程 4GB 的地址空間:低端 2GB($00000000 - $7FFFFFFF) 給使用者支配;高端 2GB($80000000 - $FFFFFFFF) 留給系統使用. 檔案或程式要調入記憶體才能工作, 先看看我們的記憶體到底有多大吧.在系統硬碟根目錄下有個 pagefile.sys

判斷網路是否串連

判斷網路的是否串連或者串連方式,比較重要的一點就是是不是即時判斷,如果你明明無串連,判斷出來卻說你有,串連上了,卻說你還未串連,下面要介紹的兩個方法中InternetGetConnectedState就是不怎麼夠即時的API函數,而第二個使用的是IsNetworkAlive這個API函數,這個沒有InternetGetConnectedState的那種問題,但是可能需要安裝SDK,也就是.Net架構。一、InternetGetConnectedState在DELPHI中引用wininet這個單元

資料字典的使用一例

字典資料表設計,table欄位設定排序讀取字典中繼資料方法procedure SetDataSet(dataset: TDataSet; const table: string);var  d: TADOQuery;  i: Integer;begin  if dataset = nil then Exit;  if not dataset.Active then Exit;  if table = '' then Exit;  d := TADOQuery.Create(nil);  try 

記錄數組存出到檔案和從檔案匯入

Type  TRecord = Record    Name: String[10];    address: String[50];  End;  TRecordFile = File Of TRecord;Var  Form1: TForm1;  aRecordFile: TRecordFile;  aRecordFileName: String = 'c:PersonS.dat';Implementation{$R *.dfm}Function

記憶體管理四

一個使用私人堆的例子:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm)  Button1: TButton;  procedure Button1Click(Sender: TObject); end;var Form1:

多標籤主介面使用TRzPageControl

// Author: CXG 2010-08-07 08:22:30unit uMain;{.$HINTS OFF}interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, Menus, RzTabs, RzSplit, RzPanel, ExtCtrls, ComCtrls, RzButton  ,ADODB, DB, ImgList,

用流讀寫結構化檔案

  unit Unit1;  interface  uses  Windows, Meages, SysUtils, Variants, Claes, Graphics, Controls, Forms,  Dialogs, StdCtrl  type  TForm1 = cla(TForm) Memo1: TMemo;{添加 Memo 顯示內容}Button1: TButto Button2: TButto procedure Button1Click(Sender: TObject); pr

記憶體管理三

VirtualAlloc 分配的記憶體是以 4K 為最小單位、連續的記憶體位址(但映射到真實的記憶體時它不一定是連續的), 前面說了, 它不適合分配小記憶體(譬如只有幾個位元組的變數); 局部的變數在 "棧" 中有程式自動管理, 那麼那些全域的小變數怎麼辦呢? 這就要用到 "堆".9 q% /+ Q1 L, }1 F2 x$ D5 D! A+ n! q4 O% a  Q5 x0 r3 Y這樣看來, VirtualAlloc 分配的記憶體既不是 "棧" 也不是 "堆"; VirtualAlloc

流的壓縮與解壓縮函數

uses Zlib;//壓縮函數procedure Zip(var fs: TMemoryStream);var  cs: TCompressionStream;  ms: TMemoryStream;  num: Integer;begin  if not(Assigned(fs) and (fs.Size>0)) then Exit;    num := fs.Size;    ms := TMemoryStream.Create;    cs :=

記憶體管理六

本例:unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;typeTForm1 = class(TForm)Button1: TButton;Button2: TButton;Memo1: TMemo;Memo2: TMemo;procedure Button1Click(Sender:

自訂訊息樣本

unit   Unit1;         interface         uses         Windows,   Messages,   SysUtils,   Classes,   Graphics,   Controls,   Forms,   Dialogs,         StdCtrls;     Const       WM_MINE=WM_USER+100;     type         TForm1   =   class(TForm)            

比較GUID是否相等

1、CompareMem(@guid1, @guid2, SizeOf(TGUID))最開始時想到的方法。查看Delphi中TGUID的定義可以看到TGUID實際上是一個結構。對於結構的比較來說最方便的就是記憶體直接比較了。TGUID = packed recordD1: LongWord;D2: Word;D3: Word;D4: array[0..7] of Byte;end;2、SysUtils.IsEqualGUID(const guid1, guid2:

TRzCheckTree的使用

1.   判斷狀態:         if   RzCheckTree1.Selected.StateIndex   =   2   then         //則為選中狀態     else   if   RzCheckTree1.Selected.StateIndex   =   1   then         //則為未選中狀態     else   if   RzCheckTree1.Selected.StateIndex   =   3   then        

INDY流的發送和接收

發送try    s := 'Hello world!';    stream := TStringStream.Create(s);    IdTCPClient1.OpenWriteBuffer;    IdTCPClient1.WriteInteger(stream.Size);//注意這裡:要先寫入流的長度,在讀取的時候如果使用      AThread.Connection.ReadStream(stream);    IdTCPClient1.WriteStream(stream,

記憶體管理二

系統給程式的地址數是 4G, 為什麼不是 3G 或 5G? 因為 32 位的指標的最大值就是 $FFFFFFFF, 它不能表示更多了, 究其根源這要回到 CPU 的定址能力、地址匯流排等等.在 Win64 下, 系統給程式的地址數達到了 16EB(0 - $FFFFFFFFFFFFFFFF), 也就是 18446744073709551616 個. 不過 Win64 還沒有普及, 我們還得回到實際的 Win32.就這 4G 的地址, 系統還要留下一半($80000000 - $FFFFFFFF,

記憶體流的使用

//用字元指標讀取流中的內容 var  pc: PChar; begin  pc := mStream.Memory;{把字元指標指向記憶體流} ShowMeage(pc[0]); //從流讀入到緩衝區 var  buffer: array[0..2] of Char;{定義個字元緩衝區}begin  mStream.Seek(0, soFromBegiing);  mStream.Read(buffer, SizeOf(buffer));  ShowMeage(buffer); {關於 See

記憶體管理五

本例在建立一個新的堆前後分別通過 GetProcessHeaps 函數擷取了當前進程的堆控制代碼列表, 沒想到一個最簡單的程式也有 5 個堆. :unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;typeTForm1 = class(TForm)Memo1: TMemo;Memo2: TMemo;Button1:

裝載HYDRA外掛程式

procedure THostForm.LoadLocalModules;var  i, x : integer;  parentnode: TTreeNode;  controller : THYModuleController;  plugindescriptor : THYPLuginDescriptor;begin  TreeView.Items.BeginUpdate;  with ModuleManager do  begin    LoadModules(GetAppPath +

給動態建立的TREE和MAINMENU關聯點擊事件

使用遞迴方法遍曆MAINMENU的所有功能表項目procedure   TFormMain.BLMenu;    procedure   GetItems(AItem:TMenuItem);     var         I:integer;     begin         AItem.OnClick := MenuTreeClick;      //功能表項目關聯點擊事件        for   I:=0   to   AItem.Count-1   do   begin       

總頁數: 61357 1 .... 4811 4812 4813 4814 4815 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.