如果您想了解CSS–SomeStructure-J.Wong的知识,那么本篇文章将是您的不二之选。同时我们将深入剖析(senderasTButton).some和TButton(sender).som
如果您想了解CSS–Some Structure - J.Wong的知识,那么本篇文章将是您的不二之选。同时我们将深入剖析(sender as TButton).some 和 TButton(sender).some 的区别是什么?、170. Two Sum III - Data structure design、ABAP 中的 include type | structure 的使用方法、ABAP中的 include type | structure 的使用方法的各个方面,并给出实际的案例分析,希望能帮助到您!
本文目录一览:- CSS–Some Structure - J.Wong
- (sender as TButton).some 和 TButton(sender).some 的区别是什么?
- 170. Two Sum III - Data structure design
- ABAP 中的 include type | structure 的使用方法
- ABAP中的 include type | structure 的使用方法
CSS–Some Structure - J.Wong
-
Layout
- Position,Layer[层次]
- Box Model
- Visual Formatting Model
- BFC[block formatting content],IFC[inline formatting content]
-
Style of Format
- Text
- Image
- Link
- Form
- Table
- CSS Reset
-
1.1 Position,Layer:
- CSS z-index 属性的使用方法和层级树的概念
About something that''s causing the problem
立即学习“前端免费学习笔记(深入)”;
-
BFC or other
- 描述问题: 某个元素包含一个子元素,子元素设置顶部负外边距,父元素随子元素向上偏移
(sender as TButton).some 和 TButton(sender).some 的区别是什么?
(sender as TButton).some 和 TButton(sender).some 的区别是什么?
(Sender as TButton) 与 TButton(Sender) 都是 Typecasting,只是语法不同
罢了, 因此, 写成 (Sender as TButton).Caption := ''Test'';或者
TButton(Sender).Caption := ''Test'';
结果都一样
针对个别物件个别事件写事件处理程序, 并不需判定 Sender为何, 因为很明
显的 Sender便是这个正在撰写的物件, 但是在多个物件共用一个事件处理程序的情况下,Sender 是谁(谁发生OnClick事件)的判断就有其必要性
if Sender = Button1 的写法是直接判定Sender是不是 Button1这个物件, 但是如果按钮有 64 个, 写 64 个 if叙述恐怕会累死人的...
因此, 以类别的判定取代个别物件的副本(instance)的判定, 应是比较简明的
作法, 於是, 我们可以写成 Sender is TButton, 为真时, 以上述型别转换的方式 --- TButton(Sender).XXXX 撰写, 就可以大辐简化程式,
毕竟,同属 TButton 的物件, 都有相同的属性(属性值不一定相同), 不是吗?
值得注意的是, Sender is (Class Name) 的 Class Name 判断是会牵涉到父阶的继承关系的, 例如: Button1 是Button,Button2是 TBitBtn, 这样的话:Button1 is TButton 为真, Button2 is TButton 也是真, 因为TBitBtn 继承自TButton, 也就是说, 球是球, 篮球也是球. 应用这个观念, 下列的程式:
if ActiveControl is TDBEdit then
(ActiveControl as TDBEdit).CutToClipboard
else
if ActiveControl is TDBMemo then
(ActiveControl as TDBMemo).CutToClipboard;
如果改成:
if ActiveControl is TCustomMemo then
TCustomMemo(ActiveControl).CutToClipboard;
程序的执行效率就更好了, 因为 TDbEdit 与 TDbMemo 的共同父阶是
TCustomMemo, 而 TCustomMemo
也有 CutToClipboard 方法
有没有试一下我的例子,就知道了。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TA = class
public
procedure Test;
end;
TB = class(TA)
public
procedure Test;
procedure Test1;
procedure Test2;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TA.Test;
begin
Showmessage(''Call TA.test'');
end;
procedure TB.Test;
begin
Showmessage(''Call TB.test'');
end;
procedure TB.Test1;
begin
(self as TA).test;
end;
procedure TB.Test2;
begin
TA(self).test;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with TB.Createdo
begin
test1;
free;
end;
{
with TB.Createdo
begin
test2;
free;
end;
}
end;
end.
www:
如果sender 与 TButton 没有关系,编译照样不通过。
170. Two Sum III - Data structure design
Design and implement a TwoSum class. It should support the following operations: add
and find
.
add
- Add the number to an internal data structure.
find
- Find if there exists any pair of numbers which sum is equal to the value.
For example,
add(1); add(3); add(5);
find(4) -> true
find(7) -> false
add快
public class TwoSum {
HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
/** Initialize your data structure here. */
public TwoSum() {
}
/** Add the number to an internal data structure.. */
public void add(int number) {
if(map.containsKey(number)){
map.put(number, map.get(number) + 1);
}else{
map.put(number, 1);
}
}
/** Find if there exists any pair of numbers which sum is equal to the value. */
public boolean find(int value) {
for(Integer i : map.keySet()){
int number = value - i;
if(map.containsKey(number)){
if(number == i && map.get(i) < 2){ //避免返回自己。add(0), find(0),这时候应该返回FALSE,因为没有这种pair.
continue;//但是如果用set的话就会返回true
}else{
return true;
}
}
}
return false;
}
}
/**
* Your TwoSum object will be instantiated and called as such:
* TwoSum obj = new TwoSum();
* obj.add(number);
* boolean param_2 = obj.find(value);
*/
search快
public class TwoSum {
Set<Integer> sum;
Set<Integer> num;
TwoSum(){
sum = new HashSet<Integer>();
num = new HashSet<Integer>();
}
// Add the number to an internal data structure.
public void add(int number) {
if(num.contains(number)){
sum.add(number * 2);
}else{
Iterator<Integer> iter = num.iterator();
while(iter.hasNext()){
sum.add(iter.next() + number);
}
num.add(number);
}
}
// Find if there exists any pair of numbers which sum is equal to the value.
public boolean find(int value) {
return sum.contains(value);
}
}
ABAP 中的 include type | structure 的使用方法
看一本书上写 include type | structure 的使用方法真是太简单了,而且没有例子。
该语句的主要作用是使别的结构体中的组件全部包括进来成为自己的组件。
比如:
REPORT z_mike_type_002.
TYPES:
BEGIN OF user,
username(10) TYPE c,
END OF user,
BEGIN OF info,
age TYPE i.
INCLUDE TYPE user.
TYPES: END OF info.
DATA my_info TYPE info.
my_info-username = ''mike''.
WRITE my_info-username.
结果为:
ABAP中的 include type | structure 的使用方法
看一本书上写 include type | structure 的使用方法真是太简单了,而且没有例子。
该语句的主要作用是使别的结构体中的组件全部包括进来成为自己的组件。
比如:
REPORT z_mike_type_002.
TYPES:
BEGIN OF user,
username(10) TYPE c,
END OF user,
BEGIN OF info,
age TYPE i.
INCLUDE TYPE user.
TYPES: END OF info.
DATA my_info TYPE info.
my_info-username = ''mike''.
WRITE my_info-username.
结果为:
今天关于CSS–Some Structure - J.Wong的介绍到此结束,谢谢您的阅读,有关(sender as TButton).some 和 TButton(sender).some 的区别是什么?、170. Two Sum III - Data structure design、ABAP 中的 include type | structure 的使用方法、ABAP中的 include type | structure 的使用方法等更多相关知识的信息可以在本站进行查询。
本文标签: