草庐IT

zip-align

全部标签

android - 将 Zip 提取到 SD 卡非常慢。我如何优化性能?

我的应用下载了一个包含大约350个文件的zip。JPG和HTML文件的混合。我为它编写的函数工作得很好,但解压缩需要永远。起初我认为原因可能是写入sd卡很慢。但是当我用手机上的其他应用程序解压缩相同的zip时,它的运行速度要快得多。我可以做些什么来优化它吗?代码如下:privatevoidextract(){try{FileInputStreaminStream=newFileInputStream(targetFilePath);ZipInputStreamzipStream=newZipInputStream(newBufferedInputStream(inStream));Zi

c++ - 在 boost 元组、zip_iterator 等上使用 std::get 和 std::tie

使用std::get()有哪些选择?和std::tie()与boost结构一起?例子:我想使用基于范围的for循环对多个容器进行迭代。我可以实现zip函数,它使用boost::zip_iterator.#include#includetemplateautozip(TContainer&...containers)->boost::iterator_range>{autozip_begin=boost::make_zip_iterator(boost::make_tuple(std::begin(containers)...));autozip_end=boost::make_zip_

c++ - 类型是否可能具有 'n-byte alignment' 以外的对齐要求

例如,考虑以下内容:假设int是4字节对齐的,long是8字节对齐的。structexample{inta;longb;intc;};编译器将其放置在内存中的明显方式是:AAAAPPPPBBBBBBBBCCCCPPPP,整个结构具有8字节对齐。P指的是一个字节的paddingA指的是a的一个字节B指的是b的一个字节C指的是c的一个字节在这种情况下,sizeof(example)是24。但另一种方法如下:AAAABBBBBBBBCCCC整个结构对齐,使得起始字节的地址mod8=4(不确定如何更简洁地说)在这种情况下,不需要填充,因此每个实例可以节省8个字节。我的问题是,是否允许编译器这样

c++ - D3D11 : How to draw a simple pixel aligned line?

我试图用D3D11在两个顶点之间画一条线。我在D3D9和D3D11中有一些经验,但在D3D11中绘制一条线似乎是一个问题,该线从一个给定像素开始并在另一个给定像素结束。我做了什么:我将0.5f添加到每个顶点的像素坐标以适应纹素/像素坐标系(我阅读了Microsoft页面以了解D3D9和D3D11坐标系之间的差异):f32fOff=0.5f;彩色顶点newVertices[2]={{D3DXVECTOR3(fStartX+fOff,fStartY+fOff,0),vecColorRGB},{D3DXVECTOR3(fEndX+fOff,fEndY+fOff,0),vecColorRGB}

file - 在 Kotlin 中创建一个 ZIP 文件

我正在尝试在Kotlin中创建一个zip文件。这是代码:funmain(args:Array){varfiles:Array=arrayOf("/home/matte/theres_no_place.png","/home/matte/vladstudio_the_moon_and_the_ocean_1920x1440_signed.jpg")varout=ZipOutputStream(BufferedOutputStream(FileOutputStream("/home/matte/Desktop/test.zip")))vardata=ByteArray(1024)for(f

file - 在 Kotlin 中创建一个 ZIP 文件

我正在尝试在Kotlin中创建一个zip文件。这是代码:funmain(args:Array){varfiles:Array=arrayOf("/home/matte/theres_no_place.png","/home/matte/vladstudio_the_moon_and_the_ocean_1920x1440_signed.jpg")varout=ZipOutputStream(BufferedOutputStream(FileOutputStream("/home/matte/Desktop/test.zip")))vardata=ByteArray(1024)for(f

c++ - g++4.9 不支持 std::align

在了解对齐问题等时,我意识到我的g++4.9(macportsOSX)实现不支持std::align。如果我尝试编译(使用-std=c++11)来自http://www.cplusplus.com/reference/memory/align/的示例代码//alignexample#include#includeintmain(){charbuffer[]="------------------------";void*pt=buffer;std::size_tspace=sizeof(buffer)-1;while(std::align(alignof(int),sizeof(cha

c++ - 我什么时候应该使用_aligned_malloc()?

我一直在阅读遗留代码,其中包含自定义内存池系统,然后我发现该代码使用了_aligned_malloc。我想知道这个功能是什么,我什么时候必须使用它。谢谢大家。我确实阅读了MSDN,但我想要的是类似“想要特定对齐的原因的一个示例是在x86上将数据与SSE指令集一起使用,其中数据必须对齐到16的倍数”。我终于明白那些代码是什么意思了。再次感谢。 最佳答案 当内存分配的对齐对您很重要时,此函数很有用。对齐是指返回的指针的数值必须能被某个数整除,即。((unsignedint)ptr)%alignment的计算结果应为0。需要特定对齐的一个

c++ - 如何使用 std::aligned_union

在尝试学习如何使用std::aligned_union时,我找不到任何示例。我的尝试遇到了我不知道如何解决的问题。structinclude{std::stringfile;};structuse{use(conststd::string&from,conststd::string&to):from{from},to{to}{}std::stringfrom;std::stringto;};std::aligned_union::typeitem;*reinterpret_cast(&item_)=use{from,to};当我尝试在VC++2013Debug模式下运行程序时,我在me

C++ zip 可变参数模板

这是C++中的一个简单的双容器zip函数:templatestd::list>simple_zip(conststd::list&lhs,conststd::list&rhs){std::list>result;for(std::pair::const_iterator,typenamestd::list::const_iterator>iter=std::pair::const_iterator,typenamestd::list::const_iterator>(lhs.cbegin(),rhs.cbegin());iter.first!=lhs.end()&&iter.secon