小编Lad*_*bro的帖子

C++中的静态函数

我在这里读了一些关于静态函数的帖子,但是在实现时遇到了麻烦.

我正在编写Dijkstra算法的硬编码示例,用于查找最短路径.

在Alg.h中声明:

static void dijkstra();
Run Code Online (Sandbox Code Playgroud)

在Alg.cpp中定义:

static void Alg::dijkstra() { 

//Create Map
Initialize();

//Loop to pass through grid multiple times
for(int i=0; i<5; i++)
{   
    current=1;  
    while(current!=6)
    {
        //Iterate through and update distances/predecessors
        //For loop to go through columns, while current iterates rows
        for(int j=1; j<7; j++)
        {
            //Check if distance from current to this node is less than
            //distance already stored in d[j] + weight of edge

            if(distanceArray[current][j]+d[current]<d[j])
            {
                //Update distance
                d[j] = distanceArray[current][j]+d[current];
                //Update predecessor
                p[j] = …
Run Code Online (Sandbox Code Playgroud)

c++ static function

18
推荐指数
3
解决办法
8万
查看次数

S3 和签名 URL:上传和检索的视频无法播放

我已经敲了几个小时的头试图弄清楚这一点:

我正在使用 Dropzone.js 使用预签名 URL 将视频文件上传到私有 S3 存储桶。目标是稍后检索该文件并使用video元素播放它。

如果我没有将 设为Content-Typexhr 请求上的文件类型,S3 会将其默认为application/octet-stream. 文件上传成功并位于存储桶中的预期位置。

当我尝试使用签名 URL 检索此文件并将其用作我的 的源时video,它不会播放 - 元素因错误而变灰。此外,如果我在浏览器中访问它,它会在我点击 URL 时下载该文件,而不是播放它。

我做了研究,发现它正在下载而不是流式传输,因为我没有指定它是视频,所以我尝试这样做。

如果我确实设置Content-Type'video/mp4'为并使用签名 URL 检索它,它既不会在视频元素中播放,也不会在浏览器中播放或下载。看起来这使得该文件由于某种原因无法使用。

我已经通过使用手动上传到 S3 的文件(而不是通过 Dropzone 上传)来验证我的检索和播放代码是否正常工作。上传过程中出现问题,无论是使用 Dropzone 还是 S3,我无法弄清楚。

amazon-s3 video-streaming dropzone.js

6
推荐指数
0
解决办法
1553
查看次数

使用Collections.sort()找不到符号错误排序集合

编辑:解决了!谢谢大家.

我正在尝试使用比较器在Java中对一个集合进行排序而没有运气.这是我的代码:

public class Collections_Exercise {

    public void runExercise(){

        String[] emailArray =  {"andy@test.com","paul@test.com","cindy@test.com", "robert@test.com", "bill@test.com", "andy@test.com", "cindy@test.com"};

        Collection<String>emails = new ArrayList<String>(Arrays.asList(emailArray));    
        processEmails(emails);

        // 5.  Call processEmails with a sorted list of emails with duplicate email addresses removed
        System.out.println("Sorted list of emails with no dups!");

        class alphabeticalComparator implements Comparator<String> 
        {
            @Override
            public int compare(String email1, String email2)
            {
                int result = email1.toString().compareTo(email2.toString());
                return result;
            }
        }

        Collections.sort(emails, new alphabeticalComparator()); //Doesn't work, can't find collections.sort() symbol
        processEmails(emails);

        private void processEmails(Collection<String> emails)
        { …
Run Code Online (Sandbox Code Playgroud)

java collections arraylist

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

在CSS中创建基于百分比的移动和Web之间的大小调整

我正在创建一个将在浏览器和移动设备上使用的Web应用程序.我的输入字段当前设置为屏幕的80%,以便为稍后要插入的图标留出空间.

我的问题是虽然80%在移动设备上看起来很棒[1]而且只为图标留下了足够的空间,但在浏览器[2]中看起来很糟糕,空间过大.增加百分比会修复浏览器,但相反会破坏移动设备等.

[1]

1 http://f.cl.ly/items/460K2T0Z3u3s2G3g3c2h/Image%202014-02-17%20at%201.17.18%20PM.png

[2]

2 http://f.cl.ly/items/3W1N3y1X3P0Q282L0U2D/Image%202014-02-17%20at%201.17.27%20PM.png

如何指定我想要留下一定数量的屏幕来插入图标,但是仍然希望输入表单根据屏幕的大小进行拉伸/缩小?

html css

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