我是新手打开mp,我尝试了一个来自官方网站的示例程序
#include <omp.h>
#include <stdio.h>
int main() {
#pragma omp parallel
printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
}
Run Code Online (Sandbox Code Playgroud)
我已经在eclipse中将库设置为项目属性 - > GCC c ++链接器中的libgomp-
但程序说/usr/bin/ld: cannot find -llibgomp我能知道我错在哪里
我在更新背景以使用9补丁图像时遇到此问题.使用不同尺寸的相同图像在不同的屏幕上布局很好,但是当我将图像更改为9个补丁时,它会神秘地打破整个布局.
之前的布局如下所示:
原始布局http://onik.org/android/layoutOk.png.
当更改为9补丁时:
9-Patch图像http://onik.org/android/layoutError.png.
XML文件保持不变,只是改变了PNG文件.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg">
<TextView
android:text="@string/title"
android:id="@+id/login_title"
android:layout_width="fill_parent"
android:layout_height="40px"
android:textSize="30px">
</TextView>
<View
android:id="@+id/login_underline"
android:layout_width="wrap_content"
android:layout_height="2px"
android:background="#aaaaaa">
</View>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:stretchColumns="1"
android:gravity="center"
android:paddingLeft="10px"
android:paddingRight="10px">
<TableRow>
<TextView
android:id="@+id/login_usernameLabel"
android:text="@string/login_usernameLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5px">
</TextView>
<EditText
android:text=""
android:id="@+id/login_username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:lines="1"
android:nextFocusDown="@+id/login_password">
</EditText>
</TableRow>
<TableRow>
<TextView
android:id="@+id/login_passwordLabel"
android:text="@string/login_passwordLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText
android:text=""
android:id="@+id/login_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:nextFocusDown="@+id/login_login"
android:inputType="textPassword">
</EditText>
</TableRow>
<TableRow android:gravity="right">
<Button
android:text="@string/login_login"
android:id="@+id/login_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button> …Run Code Online (Sandbox Code Playgroud) 嘿伙计们,每当将一个新项目添加到itemssource时,我想将列表框滚动条移动到底部,但是如果我将它传递给新添加的项目或索引,则ScrollIntoView()似乎没有做任何事情.它的.有没有人得到这个工作,或者有任何其他建议,如何我可以将列表框滚动到底部?
一些代码:
void Actions_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
//if a new item was added, set it to the selected item
if (e.NewItems != null)
{
MainListBox.SelectedIndex = e.NewStartingIndex;
//MainListBox.ScrollIntoView(MainListBox.Items.Last()); //todo: this doesnt seem to work
}
}
Run Code Online (Sandbox Code Playgroud) 可能重复:
Ruby中的i = true和false是真的吗?
Perl(或,和)和(||,&&)短路运营商之间有什么区别?
Ruby:||之间的区别 和'或'
是||一样or的Rails的?
案例A:
@year = params[:year] || Time.now.year
Events.all(:conditions => ['year = ?', @year])
Run Code Online (Sandbox Code Playgroud)
将产生以下SQL script/console:
SELECT * FROM `events` WHERE (year = 2000)
Run Code Online (Sandbox Code Playgroud)
案例B:
@year = params[:year] or Time.now.year
Events.all(:conditions => ['year = ?', @year])
Run Code Online (Sandbox Code Playgroud)
将产生以下SQL script/console:
SELECT * FROM `events` WHERE (year = NULL)
Run Code Online (Sandbox Code Playgroud) 我有这样的结构:
源代码
-|com
-|公司
-|核心--> JAVA类
-|规则 --> 文本文件
Core 内部是一个 Java 类,它使用:
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileName)));
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚要使用什么相对路径。现在我用:
“..\\..\\..\\..\\rules\\rule1.txt”
我也尝试过:
“../../../../rules/rule1.txt”
我哪里做错了?
我在UIView中有一个UIButton,它位于UIViewController中,我已经从.xib文件中分配和输入.
当将IBAction挂钩到UIButton的"Touch Down"事件时,它会正确触发.但如果我把它连接到'Touch Up Inside'事件,它就不会响应.
其他事件也不起作用.'触摸拖动输入','触摸拖动退出','触摸外部'等.仅触摸向下.
有谁知道为什么会这样?
该按钮是视图控制器中的简单圆角矩形按钮.我已经加载了视图控制器:
-(void) pushNewViewController
{
MyViewController* newViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
[self.view addSubview:newViewController.view];
[newViewController release];
}
Run Code Online (Sandbox Code Playgroud)
我在IB中将此按钮添加到圆形rect按钮到MyViewController.我创建了以下IBActions:
-(IBAction) buttonTouchDown:(id)sender
{
NSLog(@"Button Touch Down Event Fired.");
}
-(IBAction) buttonTouchUpInside:(id)sender
{
NSLog(@"Button Touch Up Inside Event Fired.");
}
Run Code Online (Sandbox Code Playgroud)
在IB I菜单中单击按钮并将Touch Down插座拖动到MyViewController并选择buttonTouchDown:.保存了IB xib.
当我运行并测试按钮并获得"Button Touch Down Event Fired"日志消息时.
但是当我回到IB并将Action更改为Touch Up Inside并将其连接到buttonTouchUpInside:IBAction并保存.我再次测试,没有得到回应.
此致,Rich
我基本上很确定这种模式必须存在并拥有一个名字......现在我称之为"门模式"......
这里是:
在我的网页的javascript中,我必须触发各种异步进程.我们不讨论如何完全异步js,但无论如何我必须触发2或3个AJAX调用,必须确定,UI构建已完成,依此类推.
只有这样,当所有这些过程完成后,我想要运行某个功能.而且恰好一次.
例
1: cropStore loaded()
2: resizeEvent()
3: productStore loaded()
Run Code Online (Sandbox Code Playgroud)
模式:在每个(成功)Ajax-load-callback结束时,GUI构建例程的结束等...我将相应的标志从false设置为true并调用gatedAction()
onEvent( 'load',
{
.... // whatever has to happen in response to cropStored, resized, etc...
// lastly:
f1 = true; //resp f2, f3, ...
gatedAction();
}
Run Code Online (Sandbox Code Playgroud)
Gate将检查标志,如果仍未设置任何标志则返回,仅调用目标函数,如果所有标志(或我称之为:gate)都打开.如果我的所有异步前置条件都只调用一次gatedAction(),我希望我可以肯定,实际的targetFunction只调用一次().
gatedAction ()
{
// Gate
if ( ! f1) return;
if ( ! f2) return;
if ( ! f3) return;
// actual Action ( <=> f1==f2==f3==true )
targetFunction();
}
Run Code Online (Sandbox Code Playgroud)
在实践中它可靠地工作.旁注:我认为java-typical(不是js-typical)同步/ volatile问题可以被忽略,因为javascript并不是真正的多线程.Afaik一个函数永远不会停在它的中间,只是为了在同一个文件运行时授予另一个javascript函数...
我经常需要这种模式,特别是对于复杂的后端UI ..(是的,我认为,我会将上面的对接丑陋的实现变成一个更可重用的javascript ...有一个gate数组和一个目标函数.)
以下代码仅用于演示目的.
假设我有2个组件(businessService和dataService)和一个UI类.
UI类需要业务服务,businessService需要dataService,而dataService需要依赖connectionString.
形成我需要解析业务服务的UI类,所以我写下面的代码:
var service = container.Resolve<BusinessService>(new { dependancy = "con string 123" }));
Run Code Online (Sandbox Code Playgroud)
请注意,dependance是connectionString构造函数参数.
但上面的代码不起作用,说dataService期望依赖性不满意.
无法创建组件'dataService',因为它具有要满足的依赖性.dataService正在等待以下依赖项:
密钥(具有特定密钥的组件) - 未注册的依赖性.
所以作为一种解决方法我这样做:
var service = container.Resolve<BusinessService>(new { dataService = container.Resolve<IDataService>(new { dependancy = "123" }) });
Run Code Online (Sandbox Code Playgroud)
但是从设计,编码风格和许多角度来看,这不是一个很好的方法.
所以,如果您可以建议为什么它不能以简单的方式工作或者您有更好的解决方法请分享.
使用jQuery的.next功能我想显示下两个项目.默认情况下,它仅选择下一个项目.
我需要控制,就像有时我需要接下来的2,有时候接下来的3
有没有办法使用自动属性显式实现接口?例如,考虑以下代码:
namespace AutoProperties
{
interface IMyInterface
{
bool MyBoolOnlyGet { get; }
}
class MyClass : IMyInterface
{
static void Main(){}
public bool MyBoolOnlyGet { get; private set; } // line 1
//bool IMyInterface.MyBoolOnlyGet { get; private set; } // line 2
}
}
Run Code Online (Sandbox Code Playgroud)
这段代码编译.但是,如果将第1行替换为第2行,则无法编译.
(这不是我需要让第2行工作 - 我只是好奇.)