开始学习laravel框架[关闭](Start learning laravel framework [closed])
我想学习php框架,laravel。 我在计算机上安装了laravel 5.2,但我不知道如何开始探索它。 那么,有没有推荐的网站让我学习laravel框架?
I want to learn php framework, laravel. I have installed laravel 5.2 on my computer but I don't know how can I start to explore it. So, is there any recommended website for me to learn laravel framework?
原文:https://stackoverflow.com/questions/38139448
最满意答案
字符串的容量大小是否总是15的倍数?
没有; 关于
std::string
容量的唯一保证是s.capacity() >= s.size()
。一个好的实现可能会使容量呈指数增长,这样每次需要重新分配底层数组时,它的容量就会扩大一倍。 这是
std::vector
所必需的,这样push_back
可以具有分期恒定的时间复杂度,但是对于std::string
没有这样的要求。另外,
std::string
实现可以执行小型字符串优化,其中比std::string
对象本身存储的字符数小于一定数量的字符,而不是存储在动态分配的数组中。 这很有用,因为很多字符串很短,动态分配可能很昂贵。 通常,如果存储字符串所需的字节数小于将指针存储到动态分配的缓冲区中所需的字节数,则会执行小型字符串优化。我不知道你的特定实现是否执行小字符串优化。
Is the capacity size of string always a multiple value of 15?
No; the only guarantee about the capacity of a
std::string
is thats.capacity() >= s.size()
.A good implementation will probably grow the capacity exponentially so that it doubles in size each time a reallocation of the underlying array is required. This is required for
std::vector
so thatpush_back
can have amortized constant time complexity, but there is no such requirement forstd::string
.In addition, a
std::string
implementation can perform small string optimizations where strings smaller than some number of characters are stored in thestd::string
object itself, not in a dynamically allocated array. This is useful because many strings are short and dynamic allocation can be expensive. Usually a small string optimization is performed if the number of bytes required to store the string is smaller than the number of bytes required to store the pointers into a dynamically allocated buffer.Whether or not your particular implementation performs small string optimizations, I don't know.
相关问答
更多-
std :: string容量大小(std::string capacity size)[2023-09-27]
字符串的容量大小是否总是15的倍数? 没有; 关于std::string容量的唯一保证是s.capacity() >= s.size() 。 一个好的实现可能会使容量呈指数增长,这样每次需要重新分配底层数组时,它的容量就会扩大一倍。 这是std::vector所必需的,这样push_back可以具有分期恒定的时间复杂度,但是对于std::string没有这样的要求。 另外, std::string实现可以执行小型字符串优化,其中比std::string对象本身存储的字符数小于一定数量的字符,而不是存储在动态 ... -
当std::vector
耗尽电力时,必须分配一个新的块。 你已经正确地说明了原因。 IMO 会增加分配器接口是有意义的。 我们中的两个人尝试使用C ++ 11,我们无法获得支持: [1] [2] 我相信为了做这个工作,需要一个额外的C级API。 我也没有得到这样的支持: [3] When std::vector runs out of capacity it has to allocate a new block. You have correctly covered the reasons. ... -
C ++:为另一个容器内的std :: vector保留容量(C++: Reserve capacity for a std::vector, which is inside another container)[2023-12-20]
你不能。 您必须循环并手动呼叫reserve 。 (就此而言, segments还没有vector ......如何在不存在的矢量中预留空间?:)) You can't. You have to loop through and call reserve manually. (And for that matter there are no vectors inside segments yet.. how could reserve space in a nonexistent vector? :) ) -
我们什么时候需要调用std :: string :: capacity()?(When do we need to call std::string::capacity()?)[2019-12-03]
这是一个很好的问题。 我将冒着火焰战争的风险,说用户代码中的capacity()调用是代码气味。 调用它的唯一原因是在操作中避免内存分配。 在这种情况下,更清晰且更容错的策略是创建一个自己的类(比如limited_length_string )。 可能的实现可能预先分配足够的内存(通过它自己的实现或通过封装std::string并在其上调用reserve() 。 如果您在代码中看到此调用,那么请注意地雷。 如果你写这个电话,那就是你的设计是可疑的信号。 It's a good question. I'm g ... -
如何将std :: vector的容量限制为元素的数量(How to limit the capacity of std::vector to the number of element)[2022-11-10]
如何将std :: vector的容量限制为元素的数量 您可以做的最好的事情是在添加元素之前保留所需的空间。 这也应该具有最佳性能,因为它没有重新分配和复制。 如果这不实用,那么你可以在添加元素后使用std::vector::shrink_to_fit() 。 当然,如果分配可能永远不会高于设定限制,那么这无济于事。 从技术上讲,标准不能保证这些方法都不符合容量和尺寸。 您依赖于标准库实现的行为。 How to limit the capacity of std::vector to the number ... -
目前还不清楚你想如何构建所有的元素。 假设您想要矢量具有n元素和容量desired_capacity ,它可能等于n 。 如果你想要n相同的元素,试试这个: std::vector
v(n, t); // creates n copies of the value t. v.reserve(desired_capacity); 如果您不想指定初始值,则可以省略: std::vector v(n); // creates n copies of T, default construct ... -
为什么矢量具有不同的容量而不是尺寸?(Why vector has different capacity and other than the size? [duplicate])[2023-08-17]
原因与向量扩展算法的本质有关。 初始化向量时,应用的额外容量数为0.在第i次需要扩展时,向量将其包含复制到新向量,其容量比当前大小加倍。 这种方法使得大小改变数组的整体思想非常有效,因为在摊销时间(意味着N次操作的平均时间),我们得到O(1)插入复杂度。 你可以看到,在我们向第一个向量添加一个整数后,我们得到的容量为6. http://coliru.stacked-crooked.com/a/f084820652f025b8 The reason is related to the very essence ... -
1)由于容量,某些内存是否被占用? 如果我没有明确保留()'d怎么办? 即使你没有调用reserve, std::string对象仍然可以为(甚至是默认构造的) std::string保留一些内存1 。 使用短字符串优化的 std::string实现也是如此 2)如果我使用std :: reserve()并且最终没有使用整个capcity那么我是在浪费内存吗? 这取决于你浪费记忆的意思; std::string动态调整其缓冲区的大小以适应std::string大小的变化。 好吧,在Short String ...
-
std :: vector preallocation(大小n,容量n + 2)(std::vector preallocation (size n, capacity n + 2))[2022-03-09]
您可以使用v.reserve(n + 2)更改vector的容量而不更改其大小。 查看文档以更好地了解正在发生的事情。 You can use v.reserve(n + 2) to change the vector's capacity without altering its size. Take a look at the documentation to better understand what is going on. -
这取决于实现,所以在切换操作系统,编译器等时不要指望相同的模式。 最常见的增长模式是1.5 * previous_capacity和2 * previous_capacity 。 在你的例子中,它似乎是前者。 有关为何选择该因子的可能解释,请参阅https://stackoverflow.com/a/1100426/784668 。 关键是它显然允许重用以前用于存储阵列的空闲内存块。 It depends on the implementation, so don't expect the same pat ...