Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

superpig

Member Since 26 May 2001
Offline Last Active Apr 04 2011 11:43 AM
-----

Topics I've Started

Gdnet Black (Alpha)

10 January 2011 - 09:44 PM

If you look at the bottom of the page, you'll see that there is now a little drop-down box that lets you change your skin (if you're logged in).

I've put together the very beginnings of a dark-based theme, for those of you who HATE THE LIGHT, SSSSSSSSS. It's more of a proto-skin at the moment, but it should allow you to read threads in a lot more comfort. I'll work through the other major pages and fix them as well in time, but I figured that some of you might like to start using it now. Be aware that it is under construction, so don't be surprised if you're browsing the site, and suddenly: POW, RIGHT IN THE KISSER. Er, I mean, the stylesheet.

So yeah. Enjoy. Let me know if you've got better palette suggestions, I'm not an artist and have really just picked shades at random most of the time.

One thing that would help me would be if anyone else is happy to contribute CSS rules to the skin. That way I can just copy and paste them in, and it'll all be done a lot faster.

(edit by Gaiiden)
Please everyone if you notice issues with the black theme, do not use the Feedback tab, but report them here so everyone can see them, offer corrections and superpig can also have all issues in one place for making edits to the theme.

Code review request: LINQ sequence split

25 March 2010 - 02:37 AM

I've just written a LINQ extension method to split a sequence up into subsequences partitioned by particular elements. Similar to String.Split, but working on any sequence, not just sequences of characters. Here's my solution. Can you find any problems with it, or suggest way to improve upon it? It strikes me as being quite a lot of code for such a simple thing.
public static class LinqExtensions
{
    private class SplitSequenceEnumerator<T> : IEnumerator<IEnumerable<T>>
    {
        private readonly IEnumerable<T> _baseSequence;
        private readonly T[] _separators;
        private IEnumerable<T> _remainingSequence;

        public SplitSequenceEnumerator(IEnumerable<T> baseSequence, T[] separators)
        {
            if(baseSequence == null) throw new ArgumentNullException("baseSequence");
            if(separators == null) separators = new T[0];

            _baseSequence = baseSequence;
            _separators = separators;
            _remainingSequence = null; // Initial state should be such that we're "before" the first elem
        }

        public void Dispose()
        {
            
        }

        public bool MoveNext()
        {
            if(_remainingSequence == null) Reset();
            _remainingSequence.SkipWhile(t => !_separators.Contains(t)).Skip(1);
            return _remainingSequence.Count() > 0;
        }

        public void Reset()
        {
            _remainingSequence = _baseSequence;
        }

        public IEnumerable<T> Current
        {
            get { return _remainingSequence.TakeWhile(t => !_separators.Contains(t)); }
        }

        object IEnumerator.Current
        {
            get { return Current; }
        }
    }

    private class SplitSequence<T> : IEnumerable<IEnumerable<T>>
    {
        private readonly IEnumerable<T> _baseSequence;
        private readonly T[] _separators;

        public SplitSequence(IEnumerable<T> baseSequence, T[] separators)
        {
            _baseSequence = baseSequence;
            _separators = separators;
        }

        public IEnumerator<IEnumerable<T>> GetEnumerator()
        {
            return new SplitSequenceEnumerator<T>(_baseSequence, _separators);
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }

    public static IEnumerable<IEnumerable<T>> Split<T>(this IEnumerable<T> xs, params T[] separators)
    {
        return new SplitSequence<T>(xs, separators);
    }
}


PARTNERS