So basically I have this
![]()
And the idea is you choose the filter button at the top and the grid is repopulated with rows containing dates only from this year.
This is just a warning about the timestamp method used being deprecated. You can add a line to a config file to change the method used, or you can just ignore it.New to mySql 5.2 and can access the workbench fine but don't understand this error when trying to access in command line. not sure if I am doing it right.
Edit: Not sure where to look for it in documentation.
![]()
This is just a warning about the timestamp method used being deprecated. You can add a line to a config file to change the method used, or you can just ignore it.
http://stackoverflow.com/questions/15701636/how-to-enable-explicit-defaults-for-timestamp
The documentation petriP linked to for datagrid went way over my head and didn't seem to apply to datagridview? Yeah, I'm lost :/
Hmmm. Interesting question.
I have a bunch of objects I need to sort and then assign continuous numbers, 1 through 300. It's the draw order for a scene.
I can (and will have to) do a boolean check of one object against another, but doing so is fairly computationally expensive. Moreover, if two objects aren't near each other, it doesn't really matter which one goes first.
How should I go about ordering this? I feel like this should be a relatively simple problem, but I'm having trouble coming up with a good approach.
Hmmm. Interesting question.
I have a bunch of objects I need to sort and then assign continuous numbers, 1 through 300. It's the draw order for a scene.
I can (and will have to) do a boolean check of one object against another, but doing so is fairly computationally expensive. Moreover, if two objects aren't near each other, it doesn't really matter which one goes first.
How should I go about ordering this? I feel like this should be a relatively simple problem, but I'm having trouble coming up with a good approach.
I do use an orthographic projection, and I do draw my sprites as billboards. However, since the camera is tilted, and the sprites always face the camera, they exist in a weird diagonal path in actual 3-D space compared to the 3-D geometry and models.From what I understand of your game, don't go this route, it will only give you trouble. Doesn't seem like a proper solution for the problem you are having. Most solutions will probably feel hacky and prone to errors as soon as the camera angle changes or you want multilayered levels.
Why not use an orthographic projection and draw your sprites as billboards? Let the hardware do the sorting for you.
I didn't spend the time to do the CS, but I'm pretty sure that this is going to reduce to sorting the whole thing, OR letting the hardware do it for you as the previous poster mentioned.Hmmm. Interesting question.
I have a bunch of objects I need to sort and then assign continuous numbers, 1 through 300. It's the draw order for a scene.
I can (and will have to) do a boolean check of one object against another, but doing so is fairly computationally expensive. Moreover, if two objects aren't near each other, it doesn't really matter which one goes first.
How should I go about ordering this? I feel like this should be a relatively simple problem, but I'm having trouble coming up with a good approach.
I proved by example that I can't just ignore certain comparisons...if I do, it messes up the merge operation. So I think you're right.I didn't spend the time to do the CS, but I'm pretty sure that this is going to reduce to sorting the whole thing, OR letting the hardware do it for you as the previous poster mentioned.
I think the unknown relationships between the objects is going to get in the way of clever solutions.
e: The buildings are presorted? That sounds potentially exploitable, although the mergesort may already be as good as you can get...
I do use an orthographic projection, and I do draw my sprites as billboards. However, since the camera is tilted, and the sprites always face the camera, they exist in a weird diagonal path in actual 3-D space compared to the 3-D geometry and models.
That's actually a cool trick, but I have no idea how they did it, and I can't really mock up 3-D environment geometry anyway...no cash for it.You are using 3d models for you characters right? Maybe you can project your background image into the 3D geometry using this trick http://www.youtube.com/watch?v=PPaH8oIJd7g
Otherwise, bubblesort is faster for a small number of elements.
That's actually a cool trick, but I have no idea how they did it, and I can't really mock up 3-D environment geometry anyway...no cash for it.
It's cool though! I know Bubble Sort could work, but it's hyper slow. Gonna roll with Merge Sort unless I hit problems.
Really? Bubble is faster than merge for lists of under 1000? Even if the comparison cost is high?I assume you have less than 1000 sprites, in that case bubblesort is probably faster.
Really? Bubble is faster than merge for lists of under 1000? Even if the comparison cost is high?
(It's going to be anywhere from 150-300 sprites, usually, depending on the mission)
char a[12][5];
char b[12][5];
swap(char *a[12][5], char *b[12][5])
{
char *temp[12][5] = a;
a = b;
b = temp;
}
The compiler seems to not let you mess with arrays the same way that you can grab a pointer to something like char **str or whatever.
Seemingly simple question but...
Is there an easy way to swap two predefined arrays in C? Like...
Code:char a[12][5]; char b[12][5]; swap(char *a[12][5], char *b[12][5]) { char *temp[12][5] = a; a = b; b = temp; } The compiler seems to not let you mess with arrays the same way that you can grab a pointer to something like char **str or whatever.
//void swap(char **a, char **b)
//{
// char **temp = a;
// a = b;
// b = temp;
//}
Really? Bubble is faster than merge for lists of under 1000? Even if the comparison cost is high?
(It's going to be anywhere from 150-300 sprites, usually, depending on the mission)
What do you mean by predefined array? It's been a while since I've done stuff in C, but would the following work?
Code://void swap(char **a, char **b) //{ // char **temp = a; // a = b; // b = temp; //}
There is a nicer way to do this with pointers without involving a temp variable, but I can't think of it right now.
edit: The above code doesn't work, I just tried it out.
Really? Bubble is faster than merge for lists of under 1000? Even if the comparison cost is high?
(It's going to be anywhere from 150-300 sprites, usually, depending on the mission)
Need more info. What is your reason for sorting a mere 300 billboards in the first place? Are they drawn with some super-expensive fragment shaders, or...?Hmmm. Interesting question.
I have a bunch of objects I need to sort and then assign continuous numbers, 1 through 300. It's the draw order for a scene.
I can (and will have to) do a boolean check of one object against another, but doing so is fairly computationally expensive. Moreover, if two objects aren't near each other, it doesn't really matter which one goes first.
How should I go about ordering this? I feel like this should be a relatively simple problem, but I'm having trouble coming up with a good approach.
You most likely don't need a fixed array. Higher dimension arrays can always be simulated with lower dimension arrays, like so:Yeah I need a fixed array basically a matrix so char ** won't work :/
char* foo = malloc(12*5); // 12x5 array
foo[x + 12*y] = 'X'; // inserting into (x, y)
free(foo);
No.Seemingly simple question but...
Is there an easy way to swap two predefined arrays in C? Like...
Code:char a[12][5]; char b[12][5]; swap(char *a[12][5], char *b[12][5]) { char *temp[12][5] = a; a = b; b = temp; } The compiler seems to not let you mess with arrays the same way that you can grab a pointer to something like char **str or whatever.
include <stdlib.h>
#include <stdio.h>
void main() {
int index;
int stack_allocated_array_2d[12][5];
int **dynamic_array_2d;
dynamic_array_2d = (int **) malloc (12 * sizeof(int *));
if (!dynamic_array_2d)
exit(1);
for (index = 12; index--; ) {
dynamic_array_2d[index] = (int *) malloc (5 * sizeof(int));
if (!dynamic_array_2d[index])
exit(1);
}
printf("%d\n", ((void *) (dynamic_array_2d[0]) == ((void *) (dynamic_array_2d))));
printf("%d\n", ((void *) (stack_allocated_array_2d[0]) == ((void *) (stack_allocated_array_2d))));
for (index = 12; index--; ) {
free (dynamic_array_2d[index]);
}
free (dynamic_array_2d);
}
If comparison cost is high, then mergestort will be better.
However, since you mentioned that the two lists may already be mostly presorted, you might want to consider Insertion Sort, which has Ocomplexity on a presorted list.
I have a bunch of dynamic objects (bullets and soldiers) and a bunch of static objects (structures). The structures (3/4ths or so of all objects) exist in a separate list to start, which is presorted. I'm sorting for draw order, which is to say, distance to camera, but it gets a little complicated if the 3-D geometry corresponding to the structure is complex.Need more info. What is your reason for sorting a mere 300 billboards in the first place? Are they drawn with some super-expensive fragment shaders, or...?
The other guys seem to know what your project is, but I don't. At least knowing which parts of the scene are dynamic and which are static, and how the camera can move, would be useful.
This.If comparison cost is high, then mergestort will be better.
However, since you mentioned that the two lists may already be mostly presorted, you might want to consider Insertion Sort, which has Ocomplexity on a presorted list.
DID IT! Any arbitrary number of soldiers and structures, correctly sorted from back to front, and all shadows falling correctly on all surfaces.
This is really the culmination of a LOT of research, asking for help, and weeks of experimenting. Doing what I'm doing is extremely weird, so I'm really happy it worked out.
Early performance tests were fine. I ended up using a generic sort on the Soldiers (just implemented IComparable<> and let .Sort() do its thing), the structures are presorted in the scene, and then a single merge pass without recursion.
WOOOOOOOOOO
Here's what it looks like in the editor:
And here's the illusion magic:
I'm starting to use mySql (ive taken a class using oracle before) and was wondering if companies prefer to use it through command line or workbench? Is there a big difference between using the two? Sorry if it sounds like a dumb question.
Is there a way to access a specific node in an already established linked list (C)? Or would I have to write a separate function for that?
What I ultimately want to do is go through a list to a specific index given by the user, insert a new node there (and put in info also given by the user) and then have that point to the rest of the list, with their data intact. I think this isn't too bad if accessing a node is similar to arrays or something.
My plan was to go to the node before the index and then make a new one, and have that point to the rest.
There is no "built-in" linked list in C, so there's no specific answer to this question. It depends on the implementation you are using.
For example, in std::list from the C++ STL, you can use find() and insert() to accomplish what you want without having to write your own method. However, linked lists are not intended to easily and efficiently support random access operations, so if you find yourself frequently needing to read data at random positions, then you should consider whether a linked list is really the right data structure to be using.
In Visual Basic 2010, how do I have all the items in a listbox multiply to form one number?
Like if I have 5,7, and 2 in the listbox, how do I make it so that they all multiply with each other to get 70?
Dim MyListSum as Double
MyListSum = 0
For n = 0 to MyList.ListCount - 1 ' index is zero based
MyListSum = MyListSum * Val(MyList.Item(n))
Next n
That restriction does not stop you from switching data structures. It means if you do switch to another structure, you have to convert to list before calling that function.:/ I figured as much. Problem is I need to pass the info later on to a function that'll only take the list, so I cant switch structures.
That restriction does not stop you from switching data structures. It means if you do switch to another structure, you have to convert to list before calling that function.
Without knowing something about the actual problem at hand, it's hard to say whether that would make sense. If this is classwork, probably not. Otherwise it would make sense pretty often. Linked lists are very rarely efficient structures for a given problem.
insert(int info, int x, node *list){
int_node *new = malloc(sizeof(node));
new->data = info;
node *temp = malloc(sizeof(node));
temp = NULL;
int i;
for(i = 0; i < (x-2); i++){
temp = list->next;
}
new->next = temp->next;
temp->next = new;
return list;
}
typedef struct node {
int data;
struct node *next;
} node;
Code:node *temp = malloc(sizeof(node)); temp = NULL;
Code:temp = NULL; int i; for(i = 0; i < (x-2); i++){ temp = list->next; } new->next = temp->next; temp->next = new; return list; }
There is a bug here. Can you see what it is?
What happens if x = 1?
1) Maybe set the next field of temp to NULL instead? Otherwise no, I don't?
When you call malloc, that allocates some memory and returns a pointer to that memory, which you store in 'temp'.
You then immediately store NULL in 'temp', overwriting the pointer to this memory. The allocated memory is then stranded forever; because you have lost the pointer to it, there is no way it can be free'd. This is what's known as a memory leak. Every time your function is called, it loses some memory. Call it enough times and your program will run out of memory and crash.
You don't need to allocate any memory for 'temp' in your function. Just declare it and assign NULL to it.
Its classwork the prof didnt finish but said will show up in some form on the exam (he wants us to know lists). I think Im getting somewhere though:
Code:insert(int info, int x, node *list){ int_node *new = malloc(sizeof(node)); new->data = info; node *temp = malloc(sizeof(node)); temp = NULL; int i; for(i = 0; i < (x-2); i++){ temp = list->next; } new->next = temp->next; temp->next = new; return list; }
So the goal is just to take some info given by the user and insert it at a position x in the list (x is like the index, and the list is also given by the user). What I tried to do is have a new node equal the node that comes before the index, and then make the node with the info given point to what the other node points to (cause I assume it will still point to the rest of the list, not sure though). This doesnt seem to work though, it compiles but then when i run it, it doesnt given an output lol.
Oh and the professor made the struct for us:
Code:typedef struct node { int data; struct node *next; } node;
class animation {
public:
animation(sf::Vector2f start, sf::Vector2f end, sf::Shape* shape, float speed);
sf::Shape& getShape(void);
bool isFinished(void);
void animate(void);
private:
sf::Vector2f start;
sf::Vector2f end;
sf::Vector2f position;
sf::Shape* shape;
sf::Vector2f direction;
float speed;
float increment;
bool finished;
};
window.draw(animation.getShape());
Still pretty new to C++, so I appreciate any help.