Treechopper
Member
So how would I go and remove empty elements from a vector in C++?
To clarify, I know that I can use erase, but how can I conviniently remove all empty cells at the same time?
You're not looking for vector<>::clear()?
So how would I go and remove empty elements from a vector in C++?
To clarify, I know that I can use erase, but how can I conviniently remove all empty cells at the same time?
You're not looking for vector<>::clear()?
Yes, shrink_to_fit seems is what I was looking. Unfortunately the compiler I use doesn't seem to have that functionality. I will try again tomorrow when Im rested.This?
http://www.cplusplus.com/reference/vector/vector/shrink_to_fit/
Alternatively, you resize() to size().
My guess is he wants to remove only the elements that are empty. Unless clear() achieves that.
For loop that removes an element if it's empty?
v.resize(v.size()); doesn't do anything. For example, here's the libstdc++ implementation:This?
http://www.cplusplus.com/reference/vector/vector/shrink_to_fit/
Alternatively, you resize() to size().
void resize(size_type __new_size)
{
if (__new_size > size())
_M_default_append(__new_size - size());
else if (__new_size < size())
_M_erase_at_end(this->_M_impl._M_start + __new_size);
}
What do you mean by 'empty'? If you can implement a function with a signature like:So how would I go and remove empty elements from a vector in C++?
To clarify, I know that I can use erase, but how can I conviniently remove all empty cells at the same time?
bool is_empty(const T& value);
v.erase(std::remove_if(v.begin(), v.end(), is_empty), v.end());
I actually find the official PostgreSQL documentation to be a pretty good guide. Check out the tutorial first and then you'll have access to everything else you could possibly want to know about the database, including internal implementation details, on the same site.Very general question, are there any particularly good resources out there for learning SQL? I'm aware of W3Schools and had a look at LSQLTHW but if seems incomplete. Any others out there?
v.resize(v.size()); doesn't do anything. For example, here's the libstdc++ implementation:
v.shrink_to_fit() is also probably not what's requested. It doesn't get rid of any elements of the vector. Pinewood mentioned wanting something like erase, and it's not really similar.
What do you mean by 'empty'? If you can implement a function with a signature like:
where T is the type of the element, then you can use std::remove_if to move the elements to the end of the vector, and erase to get rid fo them.Code:bool is_empty(const T& value);
Code:v.erase(std::remove_if(v.begin(), v.end(), is_empty), v.end());
Well, if I want to remove and element from a vector, I make the "slot" equal with NULL. How would I check that with the is_empty command?
bool is_empty(T* value) { return value == NULL; }
v.erase(std::remove(v.begin(), v.end(), NULL), v.end());
I made this because when I run my integration tests at work I basically can't do anything for 6-8 minutes. Waiting on code to compile is so passé.
I made this because when I run my integration tests at work I basically can't do anything for 6-8 minutes. Waiting on code to compile is so passé.
(original)
edit: I didn't make most of the tests. This project uses entity framework everywhere. To test almost anything you have to supply at least a dbset mock, but more likely spin up a database. So we have about 200 tests that each spin up a new database, register a ton of things with an IoC container, etc.
whats does the atoi function do in C++?
whats does the atoi function do in C++?
converts strings to integers
It may help you to remember by knowing it stands for "ascii to integer"
I downloaded the ..tarball it think it's called, from the official site.How are you installing python? If you just install it with apt-get, it'll resolve the dependencies automatically and you won't have to do anything. Just do apt-get install python3 (the package name might not be exactly that) and you're done.
I downloaded the ..tarball it think it's called, from the official site.
then compiled (i think) it, after extraction with:
./configure
make
make altinstall
At the beginning I tried with "apt-get python3" but it seemed, to me, that it installed the 3.4.0, which is already pre-installed on ubuntu, so I wasn't sure if I was installing something or not (and I read that the built-in version of python should be left alone).
I also think that modules, such as virtualenv, didn't work correctly or at all; but I've tried so many times after that, I may be misremembering. I remember that virtualenvwrapper never worked ever.
>>> import sys
>>> print(sys.version)
function show() {
if (httpRequest.readyState === 4) {
alert("response received");
if (httpRequest.status === 200) {
alert("Server Response!");
var jsObj = JSON.parse(httpRequest.responseText);
var str = "<h1><mark>INT222 - Lab 06</mark></h1>";
str += "<table>";
str += "<caption>School of ICT | Faculty of Applied Science and Engineering Technology</caption>";
str += " <thead> <tr><th>Students</th><th> Program</th><th>Semester</th><th colspan=5 id=course>Courses</th></tr></thead><tbody>";
alert(str);
for (var i = 0; i < jsObj.length; i++) {
str += "<tr><td>" + jsObj[i].name + "</td>";
str += "<td>" + jsObj[i].semester + "</td>";
str += "<td>" + jsObj[i].program + "</td>";
for (var j = 0; j < jsObj.courses.length; j++) {
str += "<td>" + jsObj[i].courses[j] + "</td>";
}
str += "</tr>";
}
str += "</tbody></table>";
document.getElementById("data").innerHTML = str;
} else {
alert("problem with request");
}
}
}
Can anyone tell me whats going on here with this JS file? Not sure why this isn't running:
So with Android Studio 1.0 anyone using this? care to comment on its quality versus other IDEs?
A related question, for someone a little familiar with Java (but has never done any mobile development), where to start with an Android development guide?
So with Android Studio 1.0 anyone using this? care to comment on its quality versus other IDEs?
A related question, for someone a little familiar with Java (but has never done any mobile development), where to start with an Android development guide?
I'm using it. It's quality for Android programming is very good in my opinion. Jetbrains makes some of the best IDE's out there, and Google built Android Studio off their IntelliJ platform.
To start with, go to Google themselves. They have an extensive development resource center with tutorials on writing some apps. There used to be a free Udacity course on building a weather app, but I'm not sure if it's available anymore. Start here
I actually find the official PostgreSQL documentation to be a pretty good guide. Check out the tutorial first and then you'll have access to everything else you could possibly want to know about the database, including internal implementation details, on the same site.
If you have a more theoretical mindset, http://www.amazon.com/dp/1449316409/?tag=neogaf0e-20 is a pretty great book for understanding the mathematics behind relational database management systems.
From what I've read:
Those are the built-in python installations, which I should "leave alone" because they're used by the system itself; installing modules (with pip) in them is not good, because if something is screwed the whole system won't work; so I should make new python installations, alongside the exiting ones.
Those are in "usr/bin", while the new ones I have to do, place themselves in "usr/local/bin" (currently empty); in these new ones I can mess as much as I want.
So I wanted to make that new coexisting installation of Python 3.4.2. I managed to do this with using the process "create/make/makealtinstall" described in my above post, but then I've had problems with modules: missing libs and modules still referring to the built-in installations, despite me doing stuff like:
export PATH="/usr/local/bin":$PATH
(and many other variants) which should point to the new interpreter in "usr/local/bin", instead of the built-in "usr/bin".
Newest XKCD:
Ain't that the truth.
I don't get it. Who gives their files such stupid names?
You'd be surprised at the common user, especially since they probably don't delete the Untitled that comes up as default on a Word Document.
I don't get it. Who gives their files such stupid names?
Forget the Documents folder, I'm scared to look at others' desktop.
Forget the Documents folder, I'm scared to look at others' desktop.
Sometimes at work we patch production (I know)...
Sometimes something comes up and we have to patch the same file again...
Sometimes when I'm annoyed and not thinking, I call the old patch 'oldPatch'.
This works fine until we need to patch again.
I'm a freshman and that sounds wayyy too complicated. Isn't there a very basic way to do this?
Definitely go with Android Studio. Especially now that it's 1.0. Eclipse/ADT will be supported for a while, I assume, but I can't think of a solid reason to stick with it, especially if you're just starting with Android.
Udacity's course is here, the "Course Materials" on Udacity are always free.
https://www.udacity.com/course/ud853
12-13 07:06:48.050 1658-1779/local.sunshine D/dalvikvm﹕ GC_FOR_ALLOC freed 214K, 7% free 4488K/4812K, paused 3ms, total 11ms
12-13 07:06:48.060 1658-1779/local.sunshine V/FetchWeatherTask﹕ Forecast Entry: Fri, Dec 12 - Clouds - 18/18
12-13 07:06:48.060 1658-1779/local.sunshine V/FetchWeatherTask﹕ Forecast Entry: Sat, Dec 13 - Rain - 21/15
12-13 07:06:48.060 1658-1779/local.sunshine V/FetchWeatherTask﹕ Forecast Entry: Sun, Dec 14 - Rain - 27/13
12-13 07:06:48.060 1658-1779/local.sunshine V/FetchWeatherTask﹕ Forecast Entry: Mon, Dec 15 - Rain - 26/16
12-13 07:06:48.060 1658-1779/local.sunshine V/FetchWeatherTask﹕ Forecast Entry: Tue, Dec 16 - Clear - 29/16
12-13 07:06:48.060 1658-1779/local.sunshine V/FetchWeatherTask﹕ Forecast Entry: Wed, Dec 17 - Rain - 32/19
12-13 07:06:48.060 1658-1779/local.sunshine V/FetchWeatherTask﹕ Forecast Entry: Thu, Dec 18 - Rain - 27/18
12-13 07:06:48.060 1658-1658/local.sunshine D/AndroidRuntime﹕ Shutting down VM
12-13 07:06:48.060 1658-1658/local.sunshine W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb0c96b20)
12-13 07:06:48.060 1658-1658/local.sunshine E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: local.sunshine, PID: 1658
java.lang.NullPointerException
at local.sunshine.ForecastFragment$FetchWeatherTask.onPostExecute(ForecastFragment.java:287)
at local.sunshine.ForecastFragment$FetchWeatherTask.onPostExecute(ForecastFragment.java:103)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Can you post output/errors you get from the console?
Change your alerts to console.log's if need be. I personally find that easier for debugging than having alerts popping up all the time.
I'm good now, thanks. Fixed it. Problem was my syntax. Tried accessing Courses where it didnt exist.
I don't really see any difference from the normal Firefox. Maybe it just makes developing FirefoxOS apps a bit easier, but that won't matter to most people.Have any of you put some time into Firefox Developer Edition?
And if so, what are your impressions?
I'm about ready to ditch Chrome altogether, and Firefox is looking to be a worthy candidate.
I have actually never encountered slow tests that were deterministic. They typically had a 1 in 1000 chance of failing. This, of course, became a problem once we had 1000 tests.I made this because when I run my integration tests at work I basically can't do anything for 6-8 minutes. Waiting on code to compile is so passé.
(original)
edit: I didn't make most of the tests. This project uses entity framework everywhere. To test almost anything you have to supply at least a dbset mock, but more likely spin up a database. So we have about 200 tests that each spin up a new database, register a ton of things with an IoC container, etc.
I made this because when I run my integration tests at work I basically can't do anything for 6-8 minutes. Waiting on code to compile is so passé.
(original)
edit: I didn't make most of the tests. This project uses entity framework everywhere. To test almost anything you have to supply at least a dbset mock, but more likely spin up a database. So we have about 200 tests that each spin up a new database, register a ton of things with an IoC container, etc.