软件的基本是要处理好”算法“及其基础(二)delphi系统原子函数及方法
如果你没有深入到delphi的内心深处,可能你不常触及这些内容。本文将不断更新增加内容,敬请关注收藏......
序号 | 函数、方法或记录 | 作用 | 引用单元 |
---|---|---|---|
001 | Trunc(ADouble:Double) | 提取浮点类型的整数部分 | System.pas |
Frac(ADouble:Double) | 提取浮点类型的小数部分 | ||
Round(X: Single):Longint; | 返回:四舍六入五留双的序数 | ||
002 | 序数相关 | System.pas | |
Ord(var X):LongInt; | 返回有序的数据类型参数对应的值的集合中的序数,不用Int64参数,返回值范围(0..MaxInt) | ||
Low(var X):LongInt; | 返回有序的数据类型参数对应的值的集合中的最小序数:(0..MaxInt) | ||
High(var X):LongInt; | 返回有序的数据类型参数对应的值的集合中的最大序数:(0..MaxInt) | ||
Pred(var X):LongInt; | 返回有序的数据类型参数对应的值的集合中的当前序数的前一个序数:(0..High(var X)-1) | ||
Succ(var X):LongInt; | 返回有序的数据类型参数对应的值的集合中的当前序数的后一个序数:(0..High(var X)-1) | ||
Odd(AInt:Integer):Boolean; | 若参数为奇数返回真 | System.pas | |
Sizeof(var X):MaxInt; | 类型或对象所占的内存字节数 | System.pas | |
003 | Inc(AInt:Integer; Incre:Integer) | 将整数AInt原子增加Incre | System.pas |
004 | Dec(AInt:Integer; Decre:Integer) | 将整数AInt原子减少Decre | System.pas |
005 | TGUID记录 | 全局唯一标识符,可由记录类方法产生或其类操作进行比较 | System.pas |
UpCase(AString:String):String | 将字符串AString大写后返回 | ||
LowerCase(AString:String):String | 将字符串AString小写后返回 | ||
Copy ( Source : string; StartChar, Count : Integer ) : string; | 因涉及多字节字符可能返回乱码,请慎用,请用System.SysUtils.TStringHelper | ||
Chr(X: Byte): Char; | 返回字节X( (0..255),即UInt8)对应的ASCii码表的码值 | ||
006 | TNotifyEvent | 标准事件Type TNotifyEvent = procedure(Sender: TObject) of object; | System.Classes.pas |
007 | TGetStrProc | 标准事件Type TGetStrProc = procedure(const S: string) of object; | System.Classes.pas |
008 | TProc TProc<T> TProc<T1,T2> TProc<T1,T2,T3> TProc<T1,T2,T3,T4>
TFunc<TResult> TFunc<T,TResult> TFunc<T1,T2,TResult> TFunc<T1,T2,T3,TResult> TFunc<T1,T2,T3,T4,TResult>
TPredicate<T>
| 通用匿名方法描述句法: type TFunc<TResult> = reference to function: TResult; TPredicate<T> = reference to function (Arg1: T): Boolean;
案例:匿名函数的定义与赋值:constructor TStringList.Create; //其中: var CompareStringsP := CompareStrings; GetObjectP := GetObject; //其中: function TStringList.CompareStrings(const S1, S2: string): Integer; function TStringList.GetObject(Index: Integer): TObject; 案例:匿名过程的定义与赋值: var LProc :TProc; //:匿名过程的声明 LProc := Procedure var LProc_1:string; LProc_2:Integer; //:匿名过程内部的变量...... begin //...... end; //:匿名过程的定义与赋值 //又如: var LStr:string; LInt:Integer; begin LStr:=''; LInt:=-1; end; | System.SysUtils.pas |
009 | Include | 常量集合(常量数组)的赋值:案例:constructor TStringList.Create; Include(FOverridden, sloCompareStrings); //其中: FOverridden: TOverridden = set of (sloCompareStrings, sloGetObject); | System.Classes.pas |
010 | TMethod | 方法记录(代码、返回数据) 及方法记录间的比较: PMethod = ^TMethod; 案例:constructor TStringList.Create; var if TMethod(CompareStringsP).Code <> @TStringList.CompareStrings then if TMethod(GetObjectP).Code <> @TStringList.GetObject then function TStringList.CompareStrings(const S1, S2: string): Integer; function TStringList.GetObject(Index: Integer): TObject; | System.pas |
011 | CompareStr等各类型比较 | 字符串比较函数://其它自己去看 function CompareStr(const S1, S2: string): Integer; | System.SysUtils //运行时刻库 //非原子单元, //但很有用 //顺便提及 |
012 | TComparer | 其中泛型比较类及其接口://下面是常见的简单的,其它Singleton及其子类客制化的自己去看 //uses System.SysUtils, System.TypInfo; type IEqualityComparer<T> = interface TComparison<T> = reference to function(const Left, Right: T): Integer; // Abstract base class for IComparer<T> implementations, and a provider TEqualityComparison<T> = reference to function(const Left, Right: T): Boolean; // Abstract base class for IEqualityComparer<T> implementations, and a provider class function Construct(const EqualityComparison: TEqualityComparison<T>; function Equals(const Left, Right: T): Boolean; 案例: while TComparer<TBitMap>.Construct( | System.Generics.Defaults 系统泛型的默认单元 |
...... | ...... | ...... | ...... |
099 | Power(const Base, Exponent: Extended): Extended; | 返回任意Base>0的实数的Exponent指数的数值 请参考网友的数学库翻译: https://blog.csdn.net/weixin_30664539/article/details/95452703 | System.Math.pas |
(AInt div BInt):Integer; | 对2个整数进行除,取商,返回Integer | ||
(AInt mod BInt):Integer; | 取2个整数相除的余数,返回Integer | ||
(AReal / BReal):real; | 2个实数或整数相除的结果,返回实数real | ||
...... | ...... | ...... | ...... |
本博客相关:
《软件的基本是要处理好”算法“及其基础(一)流-字-字符(包括某个数字、字母、符号和某个汉字等)-字符串-字节动态数组-字节-整数之间的转化关系和算法》https://blog.csdn.net/pulledup/article/details/104353336
喜欢的话,就在下面点个赞、收藏就好了,方便看下次的分享: