小编Fat*_*tie的帖子

Firebase Firestore Swift,时间戳但服务器时间?

使用 Firestore,我添加了这样的时间戳字段

    var ref: DocumentReference? = nil
    ref = Firestore.firestore()
        .collection("something")
        .addDocument(data: [
            "name": name,
            "words": words,
            "created": Timestamp(date: Date())
        ]) { ...
            let theNewId = ref!.documentID
            ...
    }
Run Code Online (Sandbox Code Playgroud)

这很好,效果很好,但它并不真正正确。应该使用 Firestore 提供的“服务器时间戳”。

请注意,这是在 iOS (Swift) 和 Firestore 上,而不是 Firebase。

获取服务器时间戳的语法是什么?

ios firebase swift google-cloud-firestore

0
推荐指数
1
解决办法
854
查看次数

排序3d点

我有一个任务是用三维对点进行排序,然后在屏幕上显示它们.它们用空格隔开.有没有比我更快的方式?

我可以把它放在三维数组中并进行某种排序功能吗?

#include <iostream>
using namespace std;
int x[1001], y[1001], z[1001];
int main()
{
int t;  // how many points
cin>>t;
for(int counter=0; counter<t; counter++)
{
    cin>>x[counter]>>y[counter]>>z[counter];
}

//sorting

for(int i=0; i<t; i++)
{
    for(int j=0; j<t; j++)
    {
        if(x[j]>=x[j+1])
        {
            int tx, ty, tz;
            tx=x[j];
            x[j]=x[j+1];
            x[j+1]=tx;
            ty=y[j];
            y[j]=y[j+1];
            y[j+1]=ty;
            tz=z[j];
            z[j]=z[j+1];
            z[j+1]=tz;
        }
        if(x[j]==x[j+1])
        {
            if(y[j]>=y[j+1])
            {
                int ty, tz;
                ty=y[j];
                y[j]=y[j+1];
                y[j+1]=ty;
                tz=z[j];
                z[j]=z[j+1];
                z[j+1]=tz;
            }
        }
        if(x[j]==x[j+1] && y[j]==y[j+1])
        {
            if(z[j]>=z[j+1])
            {
                int tz;
                tz=z[j];
                z[j]=z[j+1]; …
Run Code Online (Sandbox Code Playgroud)

c++ arrays sorting

-1
推荐指数
1
解决办法
2743
查看次数

c#泛函 - 另一个泛型的扩展

这是c#中通用方法的典型示例:

ParseObject po;

int i = po.Get<int>("someField");
string s = po.Get<string>("anotherField");
Run Code Online (Sandbox Code Playgroud)

我想写一个像这样工作的扩展 ...

 int i = po.ExampleGet<int>("someField");
 string i = po.ExampleGet<string>("anotherField");
Run Code Online (Sandbox Code Playgroud)

所以,

(a)扩展ExampleGet必须能够以与ParseObject.Get相同的方式接受<class>,并且

(b)扩展ExampleGet必须能够调用ParseObject.Get(以及做其他工作).

这种n扩展的语法是什么,它以这种方式使用泛型?

c# generics

-2
推荐指数
1
解决办法
70
查看次数

-8
推荐指数
1
解决办法
140
查看次数