Ludovic 'Archivist'
For my own tests, that is also the case for traversal if elements are bigger than a memory page
MᏫᎻᎯᎷᎷᎬᎠ
Aka 4096 bytes
Oh yes Wht Aka means?
Ludovic 'Archivist'
Oh yes Wht Aka means?
Aka = also known as
Ludovic 'Archivist'
Aka = also known as
More literally
MᏫᎻᎯᎷᎷᎬᎠ
olli
For my own tests, that is also the case for traversal if elements are bigger than a memory page
QuickBench doesn't say so http://quick-bench.com/lmsgw3u9Qph-WCSUs74tpA6eUXM
Ludovic 'Archivist'
QuickBench doesn't say so http://quick-bench.com/lmsgw3u9Qph-WCSUs74tpA6eUXM
I was speaking of searching elements, doing this very type of operation just put the load on pushing and pulling stuff, which is for sure faster in vector
Ludovic 'Archivist'
+ vector get SIMDed
olli
When you need to search quite often another data structure such as set or map may be beneficial
Vincenzo
I am sorry to bother you again but these pointers are struggling me //g++ 5.4.0 #include <iostream> #include <cstring> #include <stdio.h> #include <new> int _size=10; int *_pArray; void p (int *arr, int size){ for (int n=0;n<size;n++){ printf("%d - %d\n",n, *(arr+n)); } } int main(void) { printf("Hello, world!\n"); _pArray = new (std::nothrow) int[_size]; if (_pArray == nullptr) { return -1; } memset(_pArray, 1, _size*10); p(_pArray,_size); return 0; }output: Hello, world! 0 - 16843009 1 - 16843009 2 - 16843009 3 - 16843009 4 - 16843009 5 - 16843009 6 - 16843009 7 - 16843009 8 - 16843009 9 - 16843009
Vincenzo
where do you think is the problem?
Marie
where do you think is the problem?
https://support.google.com/websearch/answer/134479?hl=en
Anonymous
hello everyone...so sorry i know it's group for c++ learners but currently i am learning html css and php...do you know any useful websites in order to find recourses...i hv a bit difficulty while learning....i am terribly sorry one more time and my big thanks beforehand;-)
Vincenzo
well i don't have any idea where to start my research
Vincenzo
if you could at least point me where is the problme
Vincenzo
i don't understand if it is in memset or in the function p
BinaryByter
remove std::nothrow
Anonymous
/notes
Marie
/notes
Notes in chat: - cpp - cppbook - goodgoogling - googleit - ide - learn - meta - noendl - offtopic - ot - projects
BinaryByter
btw, you do memset twice
BinaryByter
and you never assign any value
Anonymous
#projects
Marie
#projects
1. Go to github.com 2. Tap on search. 3. Use advanced search. 4. Go to Advanced Search. 5. Select user's working language. 6. Press the search button. 7. Hover through the repositories and select one of them. 8. Fork it. 9. Do what you want to do. 10. Make a pull request so that the "original owner" can look at the changes and merge them if he feels the need to.
Anonymous
Hey everyone what is better to start game development in c++?
Vincenzo
btw, you do memset twice
i do it one and i assing 1!
Anonymous
SFML or Qt?
Vincenzo
BinaryByter
read my other messages
BinaryByter
btw
MᏫᎻᎯᎷᎷᎬᎠ
.
BinaryByter
next time
BinaryByter
FOR FUCK'S SAKE
BinaryByter
TELL US WHATS WRONG WITH YOUR PROGRAM
MᏫᎻᎯᎷᎷᎬᎠ
..
Vincenzo
TELL US WHATS WRONG WITH YOUR PROGRAM
i would like to fill my array with any value
Vincenzo
i am testing a function
BinaryByter
i would like to fill my array with any value
And why do you think that your current setup would do what you want to do?
Anonymous
use std::fill pls
Anonymous
Any group about c#?
Vincenzo
why size*10?
empiric test, using only _size it appear that it was filled only at the begin
Anonymous
memset only works if you want to fill an array of int with 0 or -1
Anonymous
Since it works by filling each byte with a char
Anonymous
So memset(a, 0, sizeof(a)) would result in something like 0x01010101
BinaryByter
next time you google "array of int, memset, not filled correctly"
MᏫᎻᎯᎷᎷᎬᎠ
.
BinaryByter
.
why thouhg?
MᏫᎻᎯᎷᎷᎬᎠ
Hi maxi :)
BinaryByter
MᏫᎻᎯᎷᎷᎬᎠ
Hey :)
Just came from the future
MᏫᎻᎯᎷᎷᎬᎠ
2020
BinaryByter
you didn't
MᏫᎻᎯᎷᎷᎬᎠ
C++20 is fabulous
klimi
i changed my mind ludo
@qneko i changed it again to back...
BinaryByter
C++20 is fabulous
wait for C++23
Vincenzo
no wait: //g++ 5.4.0 #include <iostream> #include <cstring> #include <stdio.h> #include <new> int _size=10; int *_pArray; void p (int arr[], int size){ for (int n=0;n<size;n++){ printf("%d - %d\n",n, arr[n]); } } int main(void) { printf("Hello, world!\n"); _pArray = new int[_size]; memset(_pArray, -1, sizeof(_pArray)); p(_pArray,_size); return 0; }output: Hello, world! 0 - -1 1 - -1 2 - 0 3 - 0 4 - 0 5 - 0 6 - 0 7 - 0 8 - 0 9 - 0
MᏫᎻᎯᎷᎷᎬᎠ
wait for C++23
I can go back there and look there :-D
Vincenzo
maybe i should do memset(_pArray, -1, sizeof(_pArray)*_size);
BinaryByter
sizeof (int) * size
Anonymous
You wouldn't want size of a pointer
BinaryByter
memset(p, -1, sizeof(int)*size)
would end up being the same on 86_64 though
BinaryByter
sizeof void* = 4
Anonymous
would end up being the same on 86_64 though
Well if it is an array of long long
BinaryByter
but in that specific case
Anonymous
Or you are on x64 system
Vincenzo
JUST USE ASN ARRAY OF CHAR
i needed an array of int
Anonymous
It's not elegant lol