import UIKit
import Metal
import QuartzCore
class ViewController: UIViewController {
var device: MTLDevice! = nil
var metalLayer: CAMetalLayer! = nil
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
device = MTLCreateSystemDefaultDevice()
metalLayer = CAMetalLayer() // 1
metalLayer.device = device // 2
metalLayer.pixelFormat = .BGRA8Unorm // 3
metalLayer.framebufferOnly = true // 4
metalLayer.frame = view.layer.frame // 5
view.layer.addSublayer(metalLayer) // 6
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources …Run Code Online (Sandbox Code Playgroud) 我有一个我在这里写的快速入口:
void swap(int& a, int& b);
int mid(int lo, int hi);
// My quicksort implementation
void sort(int vec[], int lo, int hi)
{
int mid;
if (hi > lo) {
int i = lo + 1;
int j = hi;
int p = mid(lo, hi);
swap(vec[lo], vec[p]);
mid = vec[lo];
while (i < j) {
if (vec[i] <= mid) {
i++;
} else {
while (i < --j && vec[j] >= mid);
swap(vec[i], vec[j]);
}
}
i++;
swap(vec[lo], vec[i]);
sort(vec, …Run Code Online (Sandbox Code Playgroud) 我在我的项目中将此作为 UnitTest 运行
public class RadioTest {
private static Pattern tier;
private static Pattern frequency;
private static Pattern state;
static {
tier = Pattern.compile("Tier: \\d");
frequency = Pattern.compile("Frequency: \\d{3}");
state = Pattern.compile("State: (OFF|ON)");
}
@Test
public void test() {
String title = "Tier: 2";
String title2 = "Frequency: 135";
String title3 = "State: ON";
assertTrue(tier.matcher(title).matches());
assertTrue(frequency.matcher(title2).matches());
assertTrue(state.matcher(title3).matches());
Matcher m = tier.matcher(title);
System.out.println(m.find());
System.out.println(m.group(1));
}
}
Run Code Online (Sandbox Code Playgroud)
但是我遇到了一个错误,IndexOutOfBoundsException: No group 1
我知道这与 有关m.group(1),但是有什么问题呢?在控制台中,我也true从m.find(). 我搜索了如何使用正则表达式,但它显示这样做。
我在 Eclipse 中有一个项目,我想放在 github 上,所以我去了 github 并为它们创建了 repos,但我想将它们克隆到我的 eclipse 工作区中存储文件的文件夹中。我怎样才能做到这一点?
编辑:当我尝试时,github 应用程序说它无法克隆,因为文件夹不是空的。
编辑 2:这行得通吗?在 eclipse 中更改名称以重命名项目文件夹,然后在工作区中将 repo 克隆为我想要的名称,然后重命名 eclipse 项目以便它们合并,我可以提交新文件。