首页 > 其他 > 详细

Slice 函数

时间:2015-04-16 17:01:27      阅读:251      评论:0      收藏:0      [点我收藏+]

Slice 函数

 

function Slice(var A: array; Count: Integer): array;
Slice函数把数组 A的前面Count个元素作为开放数组返回, 利用它可以方便的使用动态分配的
静态数组而且保持Delphi的数组的使用优点..
例子:
type
  TPolygon = record
    NumPoint: 0..MaxInt;
    Points  : array[1..MAX_POINTS] of TPoint;
  end;

procedure DrawPolygon(Canvas: TCanvas; const Polygon: TPolygon);
begin
  Canvas.Polygon(Slice(Polygon.Points, Polygon.NumPoint));
end;




Returns a sub-section of an array.
Unit
System
Category
miscellaneous routines
function Slice(var A: array; Count: Integer): array;
Description
Use Slice to select a sub-section (slice) of an array to be passed as an open array parameter. Slice is only allowed as a parameter in a call to a procedure or function that expects an open array parameter. Slice selects the first Count elements of the array given by A to be passed as an open array parameter. A can be an open array parameter itself, allowing dynamically allocated arrays to be passed to open array parameters.

Slice 函数

原文:http://www.cnblogs.com/moonwind/p/4432458.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!