par

为什么要在C语言中这么频繁地对结构进行typedef?

 ̄綄美尐妖づ 提交于 2020-02-26 06:24:16
我看过很多程序,其中包括以下结构 typedef struct { int i; char k; } elem; elem user; 为什么经常需要它? 有任何特定原因或适用范围? #1楼 Linux内核编码样式 第5章给出了使用 typedef 优缺点(主要是缺点)。 请不要使用“ vps_t”之类的东西。 对结构和指针使用typedef是 错误的 。 当你看到一个 vps_t a; 在源代码中是什么意思? 相反,如果说 struct virtual_container *a; 您实际上可以说出“ a”是什么。 许多人认为typedef是“帮助可读性”。 不是这样 它们仅对以下有用: (a)完全不透明的对象(使用typedef主动 隐藏 该对象是什么)。 例如:“ pte_t”等不透明对象,您只能使用适当的访问器函数来访问。 注意! 不透明和“访问器功能”本身不好。 之所以将它们用于pte_t等之类,是因为那里确实存在绝对 零的 可访问信息。 (b)清除整数类型,其中抽象 有助于 避免混淆,无论是“ int”还是“ long”。 u8 / u16 / u32是完美的typedef,尽管它们比这里更适合(d)类。 注意! 再次-需要有一个 原因 。 如果某事是“无符号的长”,则没有理由这样做 typedef unsigned long myflags_t; 但是

PAR and Win32::Exe

旧时模样 提交于 2020-01-15 07:03:22
问题 I am running Strawberry Perl on Windows 7, 32-bit. I am also using Par::Packer to create standalone executables. The problem is that PAR::Packer uses a camel icon, and I want to replace it with a different icon. To do that I am using Win32::Exe. After running Win32::Exe's update script I can change the icon, however now the executable no longer functions. After disabling the GUI flag, and enabling the console, I now get the following output: Usage: foo.exe [ -Alib.par ] [ -Idir ] [ -Mmodule ]

(R) Axis widths in gbm.plot

▼魔方 西西 提交于 2020-01-06 21:40:11
问题 Hoping for some pointers or some experiences insight as i'm literally losing my mind over this, been trying for 2 full days to set up the right values to have a function spit out clean simple line plots from the gbm.plot function (packages dismo & gbm). Here's where I start. bty=n in par to turn off the box & leave me with only left & bottom axes. Gbm.plot typically spits out one plot per explanatory variable, so usually 6 plots etc, but I'm tweaking it to do one per variable & looping it. I

(R) Axis widths in gbm.plot

时光毁灭记忆、已成空白 提交于 2020-01-06 21:36:55
问题 Hoping for some pointers or some experiences insight as i'm literally losing my mind over this, been trying for 2 full days to set up the right values to have a function spit out clean simple line plots from the gbm.plot function (packages dismo & gbm). Here's where I start. bty=n in par to turn off the box & leave me with only left & bottom axes. Gbm.plot typically spits out one plot per explanatory variable, so usually 6 plots etc, but I'm tweaking it to do one per variable & looping it. I

What is a null graphics device?

若如初见. 提交于 2019-12-30 06:16:07
问题 I'm reading the R help page for ?devAskNewPage (it was linked from ?par...ask ). I can't understand what par(ask=F) / par(ask=T) does. What do I need to read about to understand this: If the current device is the null device, this will open a graphics device. ... The precise circumstances when the user will be asked to confirm a new page depend on the graphics subsystem. Obviously this needs to be an interactive session. In addition ‘recording’ needs to be in operation, so only when the

使用Scheme模拟类和对象

自作多情 提交于 2019-12-29 20:34:03
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> a. 类和对象 函数定义可以解释为一个类,并且函数调用可以扮演对象的角色。换句话说,lambda表达式可以被视为类,而闭包可以被视为对象。 下面定义一个 point 类,lambda表达式将作为 point 类的实例对象句柄返回。这个对象句柄实际上是一个调度程序,它在给定message参数作为输入的情况下返回匹配的方法。 (define (point x y) (letrec ((getx (lambda () x)) (gety (lambda () y)) (add (lambda (p) (point (+ x (send 'getx p)) (+ y (send 'gety p))))) (type-of (lambda () 'point))) (lambda (message) (cond ((eq? message 'getx) getx) ((eq? message 'gety) gety) ((eq? message 'add) add) ((eq? message 'type-of) type-of) (else (error #f "Message not understood")))))) 在 add 方法中,我们使用 send 函数向对象发送消息。 send 函数仅查找方法,并使用

Where does pp (PAR) unpack add (-a) files?

一曲冷凌霜 提交于 2019-12-29 01:36:10
问题 This is my attempt to cut through extraneous issues raised "Why don’t my system calls work in the Perl program I wrap with pp?" I have created a simple Perl script on a linux system: new-net:~/scripts # cat ls_test.pl @ls_out = `ls -l`; map { print "$_\n" } @ls_out; $out = `sh out_test.sh`; print "$out\n"; This script calls a simple shell file: new-net:~/scripts # cat out_test.sh echo "I'm here" I used pp to pack the Perl script along with the shell script into ls_test: new-net:~/test # unzip

快速学习时序图:时序图简介、画法及实例

泪湿孤枕 提交于 2019-12-27 16:13:10
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 快速学习时序图:时序图简介、画法及实例 那只猫的鱼订阅专栏 2017-03-15 9.3万 218 37 释放双眼,带上耳机,听听看~! 00:00 00:00 时序图作为常用的UML交互图,可以直观的传达系统内外之间的交互过程,经常用在详细设计文档中。下面本文综合参考了多篇时序图的教程,根据作者的思路将时序图做了更深入的讲解。 一、 什么是时序图? 时序图(Sequence Diagram),亦称为序列图、循序图或顺序图,是一种UML交互图。它通过描述对象之间发送消息的时间顺序显示多个对象之间的动态协作。 时序图是一个二维图,横轴表示对象,纵轴表示时间,消息在各对象之间横向传递,依照时间顺序纵向排列。 二、 时序图的作用是什么? 1、展示对象之间交互的顺序。将交互行为建模为消息传递,通过描述消息是如何在对象间发送和接收的来动态展示对象之间的交互; 2、相对于其他UML图,时序图更强调交互的时间顺序; 3、可以直观的描述并发进程。 三、 组成元素有哪些? 1. 角色(Actor) 系统角色,可以是人、机器、其他系统、子系统;在时序图中用表示。 2. 对象(Object) (1)对象的三种命名方式 第一种方式包括对象名和类名,例如:直播课时:课时,在时序图中,用“对象:类”表示; 第二种方式只显示类名

Centring legend below two plots in r

荒凉一梦 提交于 2019-12-21 05:35:12
问题 I would like to centre a common legend below two plots. I have used xpd=TRUE to allow for printing outside the plot itself and oma to create space for the legend. However the legend will not move horizonatally and gets clipped 'early' vertically. Any advice? quartz(title="PCoA",12,6) par(mfrow=c(1,2),oma=c(5,0,0,0),xpd=TRUE) plot(1:3,4:6,main="plot 1") plot(1:3,4:6,main="plot 2") # Clips the plot legend(1,3.5,ncol=3,c("0-1 km","1-5 km","outside barrier"),fill=c("green","orange","red"), title=

Specify Width and Height of Plot

筅森魡賤 提交于 2019-12-18 10:53:00
问题 I have a panel containing three plots. How can I use par to specify the width and height of the main panel so it is always at a fixed size? 回答1: I usually set this at the start of my session with windows.options : windows.options(width=10, height=10) # plot away plot(...) If you need to reset to "factory settings": dev.off() windows.options(reset=TRUE) # more plotting plot(...) 回答2: You do that in the device, e.g. x11(width=4, height=6) and similarly for the file-based ones pdf("/tmp/foo.pdf"