invalidation

How safe are swift collections when used with invalidated iterators / indices?

拟墨画扇 提交于 2019-12-04 12:42:17
问题 I'm not seeing a lot of info in the swift stdlib reference. For example, Dictionary says certain methods (like remove) will invalidate indices, but that's it. For a language to call itself "safe", it needs a solution to the classic C++ footguns: get pointer to element in a vector, then add more elements (pointer is now invalidated), now use pointer, crash start iterating through a collection. while iterating, remove some elements (either before or after the current iterator position).

How to avoid blinking in Form.Invalidate()?

旧街凉风 提交于 2019-12-04 12:08:19
I'm using f.Invalidate() to repaint graphics in my C# program but the graphic blinks as it refreshes. I'm also using e.Graphics.DrawImage() inside the f_Paint() method. You need to set DoubleBuffered to true. Since it's a protected property, you'll need to make your own control: class Canvas : Control { public Canvas() { DoubleBufferred = true; } } You may need to do all of your drawing to an in memory bitmap first, then paint that bitmap to the form so that it is all drawn on screen at once. Image buffer = new Bitmap(width, height, colorDepth); //I usually use 32BppARGB as my color depth

Problem with invalidation of STL iterators when calling erase

柔情痞子 提交于 2019-12-04 11:29:40
The STL standard defines that when an erase occurs on containers such as std::deque, std::list etc iterators are invalidated. My question is as follows, assuming the list of integers contained in a std::deque, and a pair of indicies indicating a range of elements in the std::deque, what is the correct way to delete all even elements? So far I have the following, however the problem here is that the assumed end is invalidated after an erase: #include <cstddef> #include <deque> int main() { std::deque<int> deq; for (int i = 0; i < 100; deq.push_back(i++)); // range, 11th to 51st element std:

iText Stamping - Java [duplicate]

时光总嘲笑我的痴心妄想 提交于 2019-12-04 10:03:15
This question already has an answer here: how to add blank page in digitally signed pdf using java? 2 answers I am having trouble with stamping PDF documents without invalidating digital signatures. Current, I succeeded stamping a PDF. However, if the document is previously signed the signature is no longer valid. I understand why that happens, but if I use Acrobat to add text or stamp it using annotation, the signature is valid. I tried adding annotations or comments but it still invalidates the signature. Is there a way to add stamp to a PDF using iText without invalidating digital

Invalidate Session of a specific user

时光毁灭记忆、已成空白 提交于 2019-12-04 04:51:13
问题 So for my webapp, if I remove a user that is currently logged in, and I want to invalidate his/her session. So that as soon as he/she refresh the page or navigate, they are no longer log in. The way I have now is that if a User logged in successfully, I will store the user object in my SessionScoped bean, and store the HttpSession to the Application Map . Below is my code This is my SessionScoped bean @PostConstruct public void init() { User user = UserDAO.findById(userId, password); Map

Refresh / Update WPF controls like win forms

核能气质少年 提交于 2019-12-03 21:36:29
changing the text of a label (or sophisticatedly we can say a text-based progress bar). in winforms you just Invalidate / Update. But how to do this in WPF without using Background Threads. ??? public static class ExtensionMethods { private static Action EmptyDelegate = delegate() { }; public static void Refresh(this UIElement uiElement) { uiElement.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate); } } private void LoopingMethod() { for (int i = 0; i < 10; i++) { label1.Content = i.ToString(); label1.Refresh(); Thread.Sleep(500); } } Reference: http://geekswithblogs.net

Memcache invalidate entries according to a pattern?

拟墨画扇 提交于 2019-12-03 07:08:04
问题 Is there a way to invalidate entries in memcache according to a wildcard key? So if I have the following memcache keys: data/1 data/2 data/3 Is there a way I can invalidate those keys with something like data/* ? It would be extremely helpful to clear out a bunch of stale data in one swoop. 回答1: The best way is to provide a versioning key when creating your memcache key. We do this by providing a single function/method for creating a key on our system. $var1 = 123; $var2 = 456; $cacheKey =

Android: invalidate(dirty)

╄→尐↘猪︶ㄣ 提交于 2019-12-03 06:36:30
It seems like Android really doesn't like invalidate (Rect dirty) , which is used to invalidate only part of a canvas. When I invalidate part of a canvas (shown in green below) and a ToggleButton outside of the canvas needs to be redrawn at the same time, the entire region shown in red is erased! It seems as though Android is just invalidating everything within the smallest rectangle encompassing the union of the two regions that need to be redrawn, even if one of the regions is outside of the View whose canvas I'm invalidating. Is this standard behaviour, and if so, why would anyone use

How can I manually tell an owner-drawn WPF Control to refresh/redraw without executing measure or arrange passes?

僤鯓⒐⒋嵵緔 提交于 2019-12-03 04:42:50
问题 We are doing custom drawing in a control subclass's OnRender . This drawing code is based on an external trigger and data. As such, whenever the trigger fires, we need to re-render the control based on that data. What we're trying to do is find out how to force the control to re-render but without going through an entire layout pass. As stated above, most answers I've seen revolve around invalidating the Visual which invalidates the layout which forces new measure and arrange passes which is

Store and invalidate Java HttpSession from different user

最后都变了- 提交于 2019-12-02 12:13:32
问题 Okay. What I want to do is be able to, when I update a user, invalidate any session that they currently have in order to force a refresh of credentials. I don't care about being able to directly access the session-specific user data. Ideally, I would also be able to restrict users to one session by a similar manner. What I tried doing is creating a HashMap using the username as key and HttpSession as the value (my actual setup is a little more involved, but after repeated seemingly